fqcCheckout.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065
  1. <template>
  2. <gui-page
  3. :custom-header="true"
  4. :is-header-sized="false"
  5. :header-class="['gui-theme-background-color', isLandscapeScreen ? 'width: 100vmax;' : '']"
  6. :style="[isLandscapeScreen ? 'width: 100vmax' : '']"
  7. >
  8. <template #gHeader>
  9. <view
  10. :style="[isLandscapeScreen ? 'height:44px;width: 100vmax' : 'height:44px;']"
  11. class="gui-flex gui-nowrap gui-rows gui-align-items-center"
  12. >
  13. <!-- 使用组件实现返回按钮及返回首页按钮 -->
  14. <text
  15. style="font-size:44rpx;"
  16. class="gui-header-leader-btns gui-color-white font-icons"
  17. @tap="goBack"
  18. >
  19. &#xe6c5;
  20. </text>
  21. <!-- <text
  22. style="font-size:44rpx;"
  23. class="gui-header-leader-btns gui-color-white font-icons"
  24. @tap="goHome"
  25. >
  26. &#xe6c5;
  27. </text> -->
  28. <!-- 导航文本此处也可以是其他自定义内容 -->
  29. <text
  30. :style="[isPad ? 'font-size: 18px' : 'font-size: 14px']"
  31. class="gui-h4 gui-blod gui-flex1 gui-text-center gui-color-white gui-ellipsis gui-primary-text"
  32. >
  33. IQC检验
  34. </text>
  35. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  36. <!-- 实际宽度请根据自己情况设置 -->
  37. <view style="width:40px;" />
  38. </view>
  39. </template>
  40. <template #gBody>
  41. <view class="oqc-checkout">
  42. <view class="card-list-flexbox">
  43. <!-- <text class="card-list-title" :style="[isPad?'font-size: 18px':'font-size: 14px']">FQC检验信息</text> -->
  44. <!-- <view class="card-list-item">
  45. <text>日期</text>
  46. <text>{{ $parseTime(OQCParams.produceDateStr) }}</text>
  47. </view> -->
  48. <!-- <view class="card-list-item">
  49. <text>订单号</text>
  50. <text>{{ OQCParams.saleOutNo }}</text>
  51. </view>
  52. <view class="card-list-item">
  53. <text>客户名称</text>
  54. <text>{{ OQCParams.customerName }}</text>
  55. </view> -->
  56. <!-- <view class="card-list-item">
  57. <text>产品批号</text>
  58. <text>{{ OQCParams.materialLotsStr }}</text>
  59. </view> -->
  60. <!-- <view class="card-list-item">
  61. <text>产品名称</text>
  62. <text>{{ OQCParams.materialName }}</text>
  63. </view> -->
  64. <!-- <view class="card-list-item">
  65. <text>出货数量</text>
  66. <text>{{ OQCParams.deliveredQty }}</text>
  67. </view> -->
  68. <!-- <view class="card-list-item">
  69. <text>产品阶段</text>
  70. <text>{{ OQCParams.productPhase }}</text>
  71. </view> -->
  72. <!-- <view class="card-list-item">
  73. <text>班别</text>
  74. <text>{{ OQCParams.classFlag }}</text>
  75. </view> -->
  76. <!-- <view class="card-list-item">
  77. <text>有效期</text>
  78. <text>{{ OQCParams.expirationDate }}</text>
  79. </view> -->
  80. <view class="card-list-item">
  81. <text>采购订单</text>
  82. <text>{{ OQCParams.purchaseOrderNo }}</text>
  83. </view>
  84. <view class="card-list-item">
  85. <text>物料批次</text>
  86. <text>{{ OQCParams.materialLots }}</text>
  87. </view>
  88. <view class="card-list-item">
  89. <text>物料名称</text>
  90. <text>{{ OQCParams.materialName }}</text>
  91. </view>
  92. <view class="card-list-item">
  93. <text>物料编码</text>
  94. <text>{{ OQCParams.materialNo }}</text>
  95. </view>
  96. <view class="card-list-item">
  97. <text>检验数量</text>
  98. <text>{{ OQCParams.receiptQty }}</text>
  99. </view>
  100. </view>
  101. <!-- 表格 -->
  102. <view class="custom-table">
  103. <uni-table border stripe empty-text="暂无更多数据">
  104. <!-- 表头行 -->
  105. <uni-tr class="custom-table-head">
  106. <uni-th align="center" width="60px">序号</uni-th>
  107. <uni-th align="center" width="140px">是否检验</uni-th>
  108. <uni-th align="center" width="240px">检验名称</uni-th>
  109. <uni-th align="center" width="140px">巡检频次</uni-th>
  110. <uni-th align="center" width="140px">检验工具</uni-th>
  111. <uni-th align="center" width="140px">标准值</uni-th>
  112. <uni-th align="center" width="140px">修饰符</uni-th>
  113. </uni-tr>
  114. <!-- 表格数据行 -->
  115. <uni-tr
  116. v-for="(item, key) in OQCItemList"
  117. :key="key"
  118. @click="handleShowModal(item)"
  119. >
  120. <uni-td align="center" width="120px">{{ ++key }}</uni-td>
  121. <uni-td align="center">
  122. <view style="display: flex;justify-content: center;align-items: center;">
  123. <text
  124. v-if="item.completed"
  125. class="font-icons"
  126. :style="[isPad?'font-size: 24px':'font-size: 22px', 'color: #2dc252']"
  127. >
  128. &#xe6dd;
  129. </text>
  130. <text
  131. v-else
  132. class="font-icons"
  133. :style="[isPad?'font-size: 24px':'font-size: 22px', 'color: #6a6a6a']"
  134. >
  135. &#xe6e0;
  136. </text>
  137. <text v-if="item.voidOrNot*1 === 1" style="margin-left: 4px;">报废</text>
  138. <text v-else style="margin-left: 4px;">{{ item.completed? '已检': '未检' }}</text>
  139. </view>
  140. </uni-td>
  141. <uni-td
  142. align="center"
  143. :style="[item.voidOrNot*1 === 1?'text-decoration: line-through;':'']"
  144. >
  145. {{ item.inspectionName }}
  146. </uni-td>
  147. <uni-td
  148. align="center"
  149. :style="[item.voidOrNot*1 === 1?'text-decoration: line-through;':'']"
  150. >
  151. {{ item.checkQuantity }}
  152. </uni-td>
  153. <uni-td
  154. align="center"
  155. :style="[item.voidOrNot*1 === 1?'text-decoration: line-through;':'']"
  156. >
  157. {{ item.tool }}
  158. </uni-td>
  159. <uni-td
  160. align="center"
  161. :style="[item.voidOrNot*1 === 1?'text-decoration: line-through;':'']"
  162. >
  163. {{ item.standValue }}
  164. </uni-td>
  165. <uni-td
  166. align="center"
  167. :style="[item.voidOrNot*1 === 1?'text-decoration: line-through;':'']"
  168. >
  169. {{ item.standard }}
  170. </uni-td>
  171. </uni-tr>
  172. </uni-table>
  173. </view>
  174. </view>
  175. <!-- 底部弹窗 -->
  176. <uni-popup ref="popup" background-color="#fff" :mask-click="false">
  177. <view class="popup-content">
  178. <view class="card-list-flexbox-popup">
  179. <view class="card-list-item">
  180. <text class="text-1 gui-color-gray">{{ submitOQCItem.inspectionName }}</text>
  181. </view>
  182. <view class="card-list-item">
  183. <text class="text-1 gui-color-gray">检验工具</text>
  184. <text class="text-2 gui-color-gray">{{ submitOQCItem.tool }}</text>
  185. </view>
  186. <view class="card-list-item">
  187. <text class="text-1 gui-color-gray">检验频次</text>
  188. <text class="text-2 gui-color-gray">{{ submitOQCItem.checkQuantity }}</text>
  189. </view>
  190. <view class="card-list-item">
  191. <text class="text-1 gui-color-gray">检验标准</text>
  192. <text class="text-2 gui-color-gray">{{ submitOQCItem.standard }}</text>
  193. </view>
  194. <view class="card-list-item">
  195. <text class="text-1 gui-color-gray">是否合格</text>
  196. <text class="text-2 gui-color-gray">
  197. <radio-group style="width: inherit;" @change="radioChange">
  198. <view style="display: grid;grid-template-rows: 1fr; grid-template-columns: 1fr 1fr;">
  199. <label>
  200. <view style="display: flex;justify-content: center;align-items: center;">
  201. <radio value="1" :checked="submitOQCItem.singleResult*1 === 1?true:false" />
  202. <view>合格</view>
  203. </view>
  204. </label>
  205. <label>
  206. <view style="display: flex;justify-content: center;align-items: center;">
  207. <radio value="0" :checked="submitOQCItem.singleResult*1 === 0?true:false" />
  208. <view>不合格</view>
  209. </view>
  210. </label>
  211. </view>
  212. </radio-group>
  213. </text>
  214. </view>
  215. <!-- 检验模型 0 -->
  216. <view v-if="submitOQCItem.inspectionModel === 0" class="card-list-item-input">
  217. <view
  218. v-for="(item, key) in submitOQCItem.actualCreateReqVOS"
  219. :key="key"
  220. style="margin: 4px 0;"
  221. >
  222. <text
  223. v-if="item.qualified === 1"
  224. class="font-icons"
  225. style="font-size: 22px;height: auto;color: #2dc252;padding: 0 6px;"
  226. >
  227. &#xe6dd;
  228. </text>
  229. <text
  230. v-else
  231. class="font-icons"
  232. style="font-size: 22px;height: auto;color: red;padding: 0 6px;"
  233. >
  234. &#xe6e0;
  235. </text>
  236. <textarea
  237. v-model="submitOQCItem.actualCreateReqVOS[key].actual"
  238. class="text-3 gui-color-gray"
  239. inputmode="decimal"
  240. placeholder="请输入检验内容"
  241. style="border-radius: 4px;border: 1px dotted gray;"
  242. auto-height
  243. maxlength="14"
  244. />
  245. <view
  246. v-if="key === submitOQCItem.actualCreateReqVOS.length - 1"
  247. class="operation-icon"
  248. @click="appendRow(item)"
  249. >
  250. <text class="font-icons" :style="[isPad?'font-size: 18px':'font-size: 14px']">
  251. &#xe664;
  252. </text>
  253. </view>
  254. <view v-else class="operation-icon-2" @click="deleteRow(item, key)">
  255. <text class="font-icons" :style="[isPad?'font-size: 18px':'font-size: 14px']">
  256. &#xe677;
  257. </text>
  258. </view>
  259. </view>
  260. </view>
  261. <!-- 检验模型 1 -->
  262. <view v-if="submitOQCItem.inspectionModel === 1" class="card-list-item-input">
  263. <textarea
  264. v-model="submitOQCItem.measuredResults"
  265. class="text-3 gui-color-gray"
  266. inputmode="text"
  267. placeholder="请输入检验内容"
  268. style="border-radius: 4px;border: 1px dotted gray;margin: 2px 4px;"
  269. auto-height
  270. maxlength="14"
  271. />
  272. </view>
  273. <!-- 图片预览 -->
  274. <view v-if="submitOQCItem.src?.length > 0" class="card-list-item">
  275. <text class="text-1">上传图片预览:</text>
  276. </view>
  277. <view
  278. v-if="submitOQCItem.src?.length > 0"
  279. class="card-list-item grid-image"
  280. style="margin: 12px 0"
  281. >
  282. <image
  283. v-for="(item, key) in submitOQCItem.src"
  284. :key="key"
  285. :src="item"
  286. mode="scaleToFill"
  287. @click="handleRemoveImage(item, key)"
  288. />
  289. </view>
  290. <!-- 拍照 / 提交 -->
  291. <view v-if="OQCParams.auditStatus === -1" class="card-list-item">
  292. <button class="text-1 btn-mg" type="primary" @click="takePhoto">拍照</button>
  293. </view>
  294. <view class="card-list-item" style="margin: 12px 0">
  295. <button
  296. v-if="OQCParams.auditStatus === -1"
  297. class="text-1 btn-mg"
  298. type="primary"
  299. @click="handleSubmit"
  300. >
  301. 提交数据
  302. </button>
  303. <button
  304. class="text-1 btn-mg"
  305. type="default"
  306. @click="$refs['popup'].close()"
  307. >
  308. 关闭
  309. </button>
  310. </view>
  311. </view>
  312. </view>
  313. </uni-popup>
  314. <!-- 右侧悬浮菜单 -->
  315. <gui-right-menus>
  316. <template #menus-more>
  317. <view
  318. v-if="OQCParams.auditStatus === -1"
  319. hover-class="gui-tap"
  320. class="menu-items gui-bg-green gui-flex gui-columns gui-justify-content-center"
  321. @click="handleShowSubmitApprovalModal"
  322. >
  323. <text class="menu-text gui-block gui-text-center gui-color-white">送审</text>
  324. </view>
  325. <view
  326. v-else
  327. hover-class="gui-tap"
  328. class="menu-items gui-flex gui-columns gui-justify-content-center"
  329. style="background-color: #717171;"
  330. >
  331. <text class="menu-text gui-block gui-text-center gui-color-white">送审</text>
  332. </view>
  333. </template>
  334. <template #menus-primary>
  335. <view class="menu-items gui-bg-primary gui-flex gui-columns gui-justify-content-center">
  336. <text class="menu-icon gui-color-white gui-block gui-text-center gui-icons">&#xe614;</text>
  337. <text class="menu-text gui-color-white gui-block gui-text-center">操作</text>
  338. </view>
  339. </template>
  340. </gui-right-menus>
  341. <!-- 送审确认模态框 -->
  342. <gui-modal
  343. ref="modalForm"
  344. :custom-class="['gui-bg-white', 'gui-dark-bg-level-3', 'gui-border-radius']"
  345. title="提示"
  346. >
  347. <template #content>
  348. <view class="gui-padding gui-bg-gray gui-dark-bg-level-2">
  349. <text
  350. class="gui-block gui-text-center gui-text gui-color-gray"
  351. style="line-height:100rpx; padding:10rpx;"
  352. >
  353. 您确定要立即送审吗?
  354. </text>
  355. </view>
  356. </template>
  357. <template #btns>
  358. <view class="gui-flex gui-row gui-space-between operation-flex">
  359. <view hover-class="gui-tap" class="modal-btns gui-flex1" @tap="handleCancelApprovalModal">
  360. <text class="modal-btns gui-color-gray">取消</text>
  361. </view>
  362. <view class="line" />
  363. <view hover-class="gui-tap" class="modal-btns gui-flex1" @tap="handleSubmitApprovalModal">
  364. <text class="modal-btns gui-primary-color">确认</text>
  365. </view>
  366. </view>
  367. </template>
  368. </gui-modal>
  369. <!-- 错误提示 -->
  370. <uni-popup ref="errorTip" type="dialog">
  371. <uni-popup-dialog
  372. type="error"
  373. cancel-text="关闭"
  374. confirm-text="确认"
  375. title="提示"
  376. :content="errorTipMessage"
  377. @confirm="handleCloseErrorTipsModal"
  378. @close="handleCloseErrorTipsModal"
  379. />
  380. </uni-popup>
  381. </template>
  382. </gui-page>
  383. </template>
  384. <script>
  385. import axios from 'axios'
  386. import { computed, defineComponent, ref, onMounted, onBeforeMount } from 'vue'
  387. export default defineComponent({
  388. onLoad() {
  389. // // #ifdef APP-PLUS
  390. // plus.screen.lockOrientation('default');
  391. // // #endif
  392. },
  393. onUnload() {
  394. // // #ifdef APP-PLUS
  395. // plus.screen.lockOrientation('portrait-primary');
  396. // // #endif
  397. },
  398. onResize() {
  399. if ([90, -90].includes(plus.navigator.getOrientation())) {
  400. this.isLandscapeScreen = true
  401. } else {
  402. this.isLandscapeScreen = false
  403. }
  404. },
  405. setup(options) {
  406. const popup = ref()
  407. const modalForm = ref()
  408. const isLandscapeScreen = ref(false)
  409. // 直接从路径中获取id参数,优先从本地存储获取(模仿scanOutPage.vue实现)
  410. let parentRow = {}
  411. let receivedId = null
  412. try {
  413. // 方法1:优先从本地存储获取id
  414. const masterIdStr = uni.getStorageSync('masterId')
  415. if (masterIdStr) {
  416. const masterIdData = JSON.parse(masterIdStr)
  417. receivedId = masterIdData?.id
  418. console.log('从本地存储获取的id:', receivedId)
  419. // 移除已使用的本地存储数据
  420. uni.removeStorageSync('masterId')
  421. } else {
  422. // 方法2:从onLoad的options中直接获取id
  423. if (options?.id) {
  424. receivedId = options.id
  425. console.log('从options获取的id:', receivedId)
  426. } else {
  427. // 方法3:通过getCurrentPages()获取当前页面参数
  428. const pages = getCurrentPages()
  429. const currentPage = pages[pages.length - 1]
  430. if (currentPage?.options?.id) {
  431. receivedId = currentPage.options.id
  432. console.log('从currentPage.options获取的id:', receivedId)
  433. } else {
  434. // 方法4:直接解析URL获取id
  435. const url = window.location.href
  436. console.log('当前页面完整URL:', url)
  437. const idMatch = url.match(/[?&]id=([^&]+)/)
  438. if (idMatch && idMatch[1]) {
  439. receivedId = decodeURIComponent(idMatch[1])
  440. console.log('从URL解析的id:', receivedId)
  441. }
  442. }
  443. }
  444. }
  445. // 将id放入parentRow对象中,保持与原有代码结构兼容
  446. if (receivedId) {
  447. parentRow.id = receivedId
  448. console.log('parentRow对象:', parentRow)
  449. }
  450. } catch (error) {
  451. console.error('获取id参数失败:', error)
  452. }
  453. // 绑定的检查人信息
  454. const OQCParams = ref({
  455. auditStatus: null,
  456. materialLots: '',
  457. materialLotsStr: '',
  458. customerName: '',
  459. deliveredQty: '',
  460. expirationDate: '',
  461. materialName: '',
  462. produceDateStr: '',
  463. saleOutNo: '',
  464. version: 0,
  465. productPhase: '',
  466. processNo: '',
  467. materialNo: '',
  468. classFlag: '', // 班别
  469. wmsSaleOutOrderId: '',
  470. })
  471. const OQCItemList = ref([])
  472. // 待巡检项信息
  473. const submitOQCItem = ref({
  474. src: [],
  475. singleResult: '',
  476. measuredResults: null,
  477. id: '',
  478. inspectionModel: null,
  479. actualCreateReqVOS: [{ id: '', actual: 0 }],
  480. fileIds: [],
  481. })
  482. const errorState = ref(0)
  483. const errorTip = ref('')
  484. const errorTipMessage = ref('')
  485. onBeforeMount(() => {
  486. console.log('parentRow类型:', typeof parentRow)
  487. console.log('parentRow值:', parentRow)
  488. OQCParams.value.wmsSaleOutOrderId = parentRow?.id
  489. console.log('设置的wmsSaleOutOrderId:', OQCParams.value.wmsSaleOutOrderId)
  490. })
  491. onMounted(() => {
  492. handleBindOQCHeader()
  493. })
  494. const goHome = function () {
  495. uni.$goHome()
  496. }
  497. const goBack = function () {
  498. uni.$goBack('/pages/workbranch/production/FQC/fqcList')
  499. }
  500. const appendRow = function (row) {
  501. submitOQCItem.value.actualCreateReqVOS.push({ id: '', actual: '' })
  502. }
  503. const deleteRow = function (row, index) {
  504. submitOQCItem.value.actualCreateReqVOS.splice(index, 1)
  505. }
  506. // 绑定FQC检验表头
  507. const handleBindOQCHeader = async function () {
  508. await uni
  509. .$reqPost('getFQCItem', {
  510. wmsIncomingReceiptInspectionId: OQCParams.value.wmsSaleOutOrderId,
  511. })
  512. .then((data) => {
  513. OQCItemList.value = data?.list
  514. OQCParams.value.customerName = data?.customerName
  515. OQCParams.value.classFlag = data?.classFlag
  516. OQCParams.value.version = data?.version
  517. OQCParams.value.materialNo = data?.materialNo
  518. OQCParams.value.productPhase = data?.productPhase
  519. OQCParams.value.processNo = data?.processNo
  520. OQCParams.value.deliveredQty = data?.deliveredQty
  521. OQCParams.value.expirationDate = data?.expirationDate
  522. OQCParams.value.materialLotsStr = data?.materialLotsStr
  523. OQCParams.value.materialLots = data?.materialLots
  524. OQCParams.value.materialName = data?.materialName
  525. OQCParams.value.auditStatus = data?.auditStatus
  526. OQCParams.value.produceDateStr = data?.produceDateStr
  527. OQCParams.value.saleOutNo = data?.saleOutNo
  528. OQCParams.value.receiptQty = data?.receiptQty
  529. OQCParams.value.purchaseOrderNo = data?.purchaseOrderNo
  530. })
  531. }
  532. const scinumToFloat = function (num) {
  533. if (isNaN(num)) return num
  534. const str = '' + num
  535. if (!/e/i.test(str)) return num
  536. return num.toFixed(18).replace(/\.?0+$/, '')
  537. }
  538. // 开始检验
  539. const handleShowModal = function (opt) {
  540. if (opt?.voidOrNot * 1 !== 1) {
  541. Object.assign(submitOQCItem.value, opt)
  542. submitOQCItem.value.id = opt?.id
  543. submitOQCItem.value.inspectionModel = opt?.inspectionModel
  544. uni.$reqGet('getResult', { id: opt?.id }).then(({ code, data, msg }) => {
  545. if (code === 0) {
  546. if (popup.value?.showPopup === false) popup.value.open('bottom')
  547. if (
  548. data.actualDOS !== null &&
  549. Object.prototype.toString.call(data.actualDOS) === '[object Array]' &&
  550. data.actualDOS.length > 0
  551. ) {
  552. submitOQCItem.value.actualCreateReqVOS.length = 0
  553. data?.actualDOS.forEach((item) => {
  554. const actual = scinumToFloat(item?.actual)
  555. submitOQCItem.value.actualCreateReqVOS.push({ ...item, actual })
  556. })
  557. } else {
  558. submitOQCItem.value.actualCreateReqVOS = [{ id: '', actual: '' }]
  559. }
  560. if (data.fileIds !== null) submitOQCItem.value.fileIds = data?.fileIds ?? []
  561. submitOQCItem.value.measuredResults = data?.measuredResults ?? ''
  562. submitOQCItem.value.src = data?.urlList ?? []
  563. } else {
  564. // #ifdef APP-PLUS
  565. plus.device.beep(2)
  566. // #endif
  567. errorTipMessage.value = msg
  568. errorTip.value.open()
  569. errorState.value = -1
  570. }
  571. })
  572. }
  573. }
  574. const handleSubmit = async function () {
  575. const actualCreateReqVOS = []
  576. if (submitOQCItem.value.inspectionModel === 0) {
  577. try {
  578. submitOQCItem.value.actualCreateReqVOS.forEach((item) => {
  579. if (isNaN(Number(item.actual))) {
  580. throw new Error('请填写正确的数值!')
  581. } else {
  582. actualCreateReqVOS.push({ id: '', ...item, actual: item.actual })
  583. }
  584. })
  585. } catch (e) {
  586. uni.showToast({ title: e.message, duration: 2000, icon: 'none' })
  587. return
  588. }
  589. }
  590. const params = {
  591. fileIds: submitOQCItem.value.fileIds,
  592. actualCreateReqVOS,
  593. singleResult: submitOQCItem.value.singleResult,
  594. measuredResults: submitOQCItem.value.measuredResults,
  595. id: submitOQCItem.value.id,
  596. materialLots: OQCParams.value.materialLots,
  597. inspectionModel: submitOQCItem.value.inspectionModel,
  598. processNo: OQCParams.value.processNo,
  599. }
  600. if (params.singleResult === '□OK ■NG') params.singleResult = '0'
  601. else if (params.singleResult === '■OK □NG') params.singleResult = '1'
  602. const data = await uni.$reqPut('submitItem', params)
  603. if (data?.code === 0) {
  604. uni.showToast({ title: '数据提交成功!', duration: 2000, icon: 'none' })
  605. popup.value.close()
  606. handleBindOQCHeader()
  607. } else {
  608. // #ifdef APP-PLUS
  609. plus.device.beep(2)
  610. // #endif
  611. errorTipMessage.value = data?.msg ?? ''
  612. errorTip.value.open()
  613. errorState.value = -1
  614. }
  615. }
  616. // 拍照
  617. const takePhoto = function () {
  618. uni.chooseImage({
  619. count: 6,
  620. sizeType: ['original', 'compressed'],
  621. sourceType: ['album', 'camera'],
  622. success: function (res) {
  623. res.tempFilePaths.forEach(async (item) => {
  624. // #ifdef APP-PLUS
  625. await uni.uploadFile({
  626. url: uni.$baseUrl + '/admin-api/minio/files/uploadFiles',
  627. name: 'file',
  628. filePath: item,
  629. header: { Authorization: 'Bearer ' + uni.getStorageSync('token') },
  630. success: function (uploadFileRes) {
  631. const resultJSON = JSON.parse(uploadFileRes.data)
  632. if (submitOQCItem.value.fileIds === null) submitOQCItem.value.fileIds = []
  633. submitOQCItem.value.fileIds.push(resultJSON.data.fileId)
  634. },
  635. })
  636. // #endif
  637. submitOQCItem.value.src.push(item)
  638. })
  639. res.tempFiles.forEach(async (item) => {
  640. // #ifdef H5
  641. const formData = new FormData()
  642. formData.append('file', item)
  643. const { data } = await axios({
  644. url: uni.$baseUrl + '/admin-api/minio/files/uploadFiles',
  645. name: '上传文件',
  646. method: 'post',
  647. headers: {
  648. Authorization: 'Bearer ' + uni.getStorageSync('token'),
  649. 'Content-Type': 'multipart/form-data;',
  650. },
  651. data: formData,
  652. })
  653. if (submitOQCItem.value.fileIds === null) submitOQCItem.value.fileIds = []
  654. submitOQCItem.value.fileIds.push(data.data.fileId)
  655. // #endif
  656. })
  657. },
  658. })
  659. }
  660. const radioChange = function (item) {
  661. submitOQCItem.value.singleResult = item?.detail?.value
  662. }
  663. const handleRemoveImage = function (opt, index) {
  664. submitOQCItem.value.fileIds.splice(index, 1)
  665. submitOQCItem.value.src.splice(index, 1)
  666. }
  667. const handleShowSubmitApprovalModal = function () {
  668. modalForm.value.open()
  669. }
  670. const handleCancelApprovalModal = function () {
  671. modalForm.value.close()
  672. }
  673. const handleSubmitApprovalModal = function () {
  674. const params = {
  675. version: OQCParams.value.version,
  676. materialLots: OQCParams.value.materialLots,
  677. processNo: OQCParams.value.processNo,
  678. materialNo: OQCParams.value.materialNo,
  679. }
  680. uni.$reqPost('submitApproval', params)
  681. .then(({ code, data, msg }) => {
  682. if (code === 0) {
  683. uni.showToast({ title: '送审成功!', duration: 2000, icon: 'none' })
  684. handleBindOQCHeader()
  685. } else {
  686. uni.showToast({ title: msg, duration: 2000, icon: 'none' })
  687. }
  688. })
  689. .finally(() => {
  690. modalForm.value.close()
  691. })
  692. }
  693. const handleCloseErrorTipsModal = async function () {
  694. errorTip.value.close()
  695. }
  696. return {
  697. goHome,
  698. popup,
  699. goBack,
  700. modalForm,
  701. takePhoto,
  702. OQCItemList,
  703. errorState,
  704. errorTip,
  705. errorTipMessage,
  706. appendRow,
  707. deleteRow,
  708. isLandscapeScreen,
  709. OQCParams,
  710. radioChange,
  711. handleBindOQCHeader,
  712. handleShowModal,
  713. handleSubmit,
  714. submitOQCItem,
  715. handleRemoveImage,
  716. handleShowSubmitApprovalModal,
  717. handleCancelApprovalModal,
  718. handleSubmitApprovalModal,
  719. handleCloseErrorTipsModal,
  720. }
  721. },
  722. })
  723. </script>
  724. <style lang="scss" scoped>
  725. .gui-header-leader-btns {
  726. color: black;
  727. font-size: 24px !important;
  728. margin-left: 24rpx;
  729. }
  730. .gui-sbody {
  731. background-color: rgba(234, 239, 242, 1);
  732. }
  733. .gui-relative {
  734. overflow: visible;
  735. height: 100vh;
  736. .oqc-checkout {
  737. width: 100vw;
  738. height: calc(100vh - 75px);
  739. position: absolute;
  740. top: 95px;
  741. overflow: hidden;
  742. }
  743. }
  744. .card-list-flexbox {
  745. width: calc(100vw - 24px);
  746. margin: 0 12px;
  747. display: flex;
  748. justify-content: center;
  749. flex-direction: column;
  750. align-items: center;
  751. overflow-y: scroll;
  752. .card-list-title {
  753. width: 100%;
  754. height: 35px;
  755. line-height: 35px;
  756. margin: 0 4px 0 4px;
  757. border-radius: 4px 4px 0 0;
  758. text-align: center;
  759. color: white;
  760. background-color: rgba(0, 160, 233, 1);
  761. }
  762. .card-list-item,
  763. .card-list-item-operation {
  764. width: 100%;
  765. height: 35px;
  766. margin: 0 4px 3rpx 4px;
  767. border-radius: 4px;
  768. display: flex;
  769. flex-direction: row;
  770. align-items: center;
  771. justify-content: space-between;
  772. background-color: #fff;
  773. uni-text {
  774. font-size: 14px;
  775. height: 50rpx;
  776. text-align: left;
  777. padding: 0 8px;
  778. display: flex;
  779. flex-direction: row;
  780. align-items: center;
  781. }
  782. .text-1 {
  783. flex: 1;
  784. height: 35px;
  785. justify-content: flex-start;
  786. }
  787. .text-2 {
  788. flex: 3;
  789. height: 35px;
  790. justify-content: flex-end;
  791. margin-right: 4px;
  792. padding: 2px 6px;
  793. }
  794. }
  795. }
  796. .popup-content {
  797. width: 100vw;
  798. height: 55vh;
  799. overflow-y: scroll;
  800. }
  801. .card-list-flexbox-popup {
  802. width: 100vw;
  803. display: flex;
  804. flex-direction: row;
  805. align-items: center;
  806. flex-wrap: wrap;
  807. .card-list-item,
  808. .card-list-item-input {
  809. width: 100vw;
  810. height: 100%;
  811. min-height: 40px;
  812. display: flex;
  813. flex-direction: row;
  814. align-items: center;
  815. background-color: #fff;
  816. uni-text {
  817. font-size: 14px;
  818. height: 50rpx;
  819. text-align: left;
  820. padding: 0 12px;
  821. display: flex;
  822. flex-direction: row;
  823. align-items: center;
  824. }
  825. uni-image {
  826. width: calc(100vw / 2 - 4px);
  827. height: calc(100vw / 3.2 - 2px);
  828. pointer-events: none;
  829. }
  830. uni-image::after {
  831. content: '×';
  832. width: 22px;
  833. height: 22px;
  834. position: absolute;
  835. top: 5px;
  836. right: 5px;
  837. display: flex;
  838. justify-content: center;
  839. align-items: center;
  840. color: rgba(255, 255, 255, 0.9);
  841. background-color: rgba(0, 0, 0, 0.5);
  842. border-radius: 50%;
  843. font-size: 24px;
  844. pointer-events: auto;
  845. }
  846. .text-1 {
  847. flex: 1;
  848. height: 40px;
  849. justify-content: flex-start;
  850. }
  851. .text-2 {
  852. flex: 3;
  853. height: 40px;
  854. justify-content: flex-end;
  855. margin-right: 4px;
  856. padding: 2px 6px;
  857. }
  858. .text-3 {
  859. width: calc(100% - 15%);
  860. min-height: 35px;
  861. justify-content: flex-end;
  862. padding: 2px 6px;
  863. }
  864. .btn-mg {
  865. margin: 0 5px;
  866. }
  867. }
  868. .card-list-item {
  869. justify-content: center;
  870. }
  871. .card-list-item-input {
  872. margin: 10px 0 10px 2%;
  873. display: flex;
  874. flex-direction: column;
  875. uni-view {
  876. width: 100%;
  877. height: 100%;
  878. display: flex;
  879. uni-textarea {
  880. flex: 8;
  881. }
  882. uni-view {
  883. flex: 1;
  884. }
  885. .operation-icon,
  886. .operation-icon-2 {
  887. height: auto;
  888. uni-text {
  889. width: 22px;
  890. height: 100%;
  891. padding: 0 !important;
  892. text-align: center;
  893. display: flex;
  894. justify-content: center;
  895. align-items: center;
  896. border-top-right-radius: 4px;
  897. border-bottom-right-radius: 4px;
  898. color: white;
  899. background-color: #80b7ff;
  900. }
  901. }
  902. .operation-icon-2 {
  903. uni-text {
  904. background-color: #ff5962;
  905. }
  906. }
  907. }
  908. }
  909. .grid-image {
  910. display: grid;
  911. grid-template-rows: repeat(auto-fill, 1fr);
  912. grid-template-columns: repeat(2, 1fr);
  913. padding: 0 4px;
  914. }
  915. .card-list-item:nth-of-type(1) {
  916. .text-1 {
  917. flex: 9;
  918. font-weight: bold;
  919. color: black !important;
  920. }
  921. .text-1::before {
  922. content: '';
  923. width: 4px;
  924. height: 20px;
  925. border-radius: 4px;
  926. margin-right: 4px;
  927. background-color: skyblue;
  928. }
  929. .text-2 {
  930. flex: 4;
  931. display: flex;
  932. flex-direction: row;
  933. justify-content: flex-end;
  934. align-items: center;
  935. color: limegreen !important;
  936. }
  937. }
  938. }
  939. .custom-table {
  940. height: calc(100vh - 300px);
  941. margin: 5px 0;
  942. overflow-y: scroll;
  943. }
  944. .uni-list-cell {
  945. width: 100vw;
  946. height: 35px;
  947. margin: 4px 0;
  948. display: flex;
  949. flex-direction: row;
  950. align-items: center;
  951. justify-content: space-between;
  952. border-bottom: 2px solid #eaeff2;
  953. background-color: #fff;
  954. view {
  955. font-size: 14px;
  956. height: 50rpx;
  957. text-align: left;
  958. padding: 0 8px;
  959. display: flex;
  960. flex-direction: row;
  961. align-items: center;
  962. }
  963. .uni-list-cell-left {
  964. flex: 1;
  965. height: 35px;
  966. justify-content: flex-start;
  967. }
  968. .uni-list-cell-db {
  969. flex: 3;
  970. height: 35px;
  971. justify-content: flex-end;
  972. margin-right: 4px;
  973. padding: 2px 6px;
  974. uni-picker {
  975. width: 100%;
  976. display: flex;
  977. flex-direction: row;
  978. justify-content: center;
  979. }
  980. }
  981. }
  982. .modal-btns {
  983. height: 100rpx;
  984. line-height: 100rpx;
  985. display: flex;
  986. justify-content: center;
  987. align-items: center;
  988. }
  989. .line {
  990. margin-top: 10rpx;
  991. height: 80rpx;
  992. width: 1rpx;
  993. background-color: #dcdcdc;
  994. }
  995. </style>