form.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="carrier-info uni-column">
  4. <view class="carrier-code uni-row">
  5. <text>箱号</text>
  6. <text style="margin-left: 24rpx;">{{processInspecion.lot.allCarrierName}}</text>
  7. </view>
  8. <view class="info-row uni-row">
  9. <view class="label">图号</view>
  10. <view class="value">{{ processInspecion.lot.drawingNumber }}</view>
  11. </view>
  12. <view class="info-row uni-row">
  13. <view class="label">批次号</view>
  14. <view class="value">{{ processInspecion.lot.lotCode }}</view>
  15. </view>
  16. <view class="info-row uni-row">
  17. <view class="label">工艺版本</view>
  18. <view class="value">{{ processInspecion.lot.technologyVersion }}</view>
  19. </view>
  20. <view class="info-row uni-row">
  21. <view class="label">产品描述</view>
  22. <view class="value">{{processInspecion.lot.productDescription }}</view>
  23. </view>
  24. <view class="info-row uni-row">
  25. <view class="label">外协工序</view>
  26. <view class="value">{{ processInspecion.processNames }}</view>
  27. </view>
  28. <view class="info-row uni-row">
  29. <view class="label">投产数量</view>
  30. <view class="value">{{ processInspecion.lot.pudName }}</view>
  31. </view>
  32. <view class="info-row uni-row">
  33. <view class="label">检查载具</view>
  34. <view class="value">{{ processInspecion.inspectionCarrierCode }}
  35. {{ processInspecion.isInspectionCarrierChanged == 1 ? '(已解绑)' : ''}}
  36. </view>
  37. </view>
  38. <view class="info-row uni-row">
  39. <view class="drawing-btn" @click="handleDrawingMenu">图纸信息</view>
  40. </view>
  41. </view>
  42. <!-- 废品信息 -->
  43. <view class="title unfit-title uni-row">
  44. <text>检查信息</text>
  45. <view v-if="editable()" class="add-btn" @click="handleAddWaste">添加</view>
  46. </view>
  47. <view class="unfit-container">
  48. <view class="unfit-item-container uni-column" v-for="(item, index) in oldUnfitInfos" :key="index">
  49. <view class="resu uni-row">
  50. <view class="label">检查标准</view>
  51. <view class="value">{{ item.checkStandard }}</view>
  52. </view>
  53. <view class="resu uni-row">
  54. <view class="label">检查结果</view>
  55. <view class="value">{{ item.checkResult }}</view>
  56. </view>
  57. <view class="resu uni-row">
  58. <view class="label">超差范围</view>
  59. <view class="value">{{ item.exceedLimits }}</view>
  60. </view>
  61. <view class="resu uni-row">
  62. <view :class="'label'">检查量</view>
  63. <view class="number value">{{ item.examiningNum }}</view>
  64. <view :class="'label'">不良品量</view>
  65. <view class="value">{{ item.disqualificationNum }}</view>
  66. <view :class="'label'">废品量</view>
  67. <view class="value">{{ item.rejectNum }}</view>
  68. </view>
  69. </view>
  70. <view class="unfit-item-container uni-column" v-for="(item, index) in unfitInfos" :key="index">
  71. <!-- 暂时注释,后续会使用 -->
  72. <!-- <view class="title uni-row">
  73. <text>检查项-{{ item.title }}</text>
  74. <uni-icons type="trash" size="24" color="#fc6565" @click="handleDelWaste(index)" />
  75. </view> -->
  76. <!-- <view class="standard">检查标准:{{ item.standard }}</view> -->
  77. <view class="resu uni-row">
  78. <view class="label">检查标准</view>
  79. <view class="value" style="margin-left:16rpx;width: 400rpx;">{{ item.checkStandard }}</view>
  80. <uni-icons v-if="editable()" type="trash" size="24" style="margin-left: 55rpx;" color="#fc6565"
  81. @click="handleDelWaste(index)" />
  82. </view>
  83. <!-- <view class="result uni-row">
  84. <view class="label">检查结果</view>
  85. <input v-model="item.checkResult" placeholder="请输入检查结果" />
  86. <view class="label" style="text-align: right; padding-right: 16rpx;">数量
  87. </view>
  88. <input class="number" type="number" @blur="rejectNumberChange" v-model="item.rejectNum"
  89. placeholder="" />
  90. </view> -->
  91. <view class="resu uni-row">
  92. <view class="label">检查结果</view>
  93. <input v-if="editable()" v-model="item.checkResult" placeholder="请输入检查结果" maxlength="50" />
  94. <view v-else class="value" style="margin-left:16rpx;">{{ item.checkResult }}</view>
  95. </view>
  96. <view class="resu uni-row">
  97. <view class="label">超差范围</view>
  98. <input v-if="editable()" v-model="item.exceedLimits" placeholder="请输入超差范围" maxlength="50" />
  99. <view v-else class="value" style="margin-left:16rpx;">{{ item.exceedLimits }}</view>
  100. </view>
  101. <view class="resu uni-row">
  102. <view :class="!editable() ? 'label' : ''">检查量</view>
  103. <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  104. v-model="item.examiningNum" placeholder="" />
  105. <view v-else class="number value" style="margin-left:16rpx;">{{ item.examiningNum }}</view>
  106. <view :class="!editable() ? 'label' : ''">不良品量</view>
  107. <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  108. v-model="item.disqualificationNum" placeholder="" />
  109. <view v-else class="number value" style="margin-left:16rpx;">{{ item.disqualificationNum }}</view>
  110. <view :class="!editable() ? 'label' : ''">废品量</view>
  111. <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  112. v-model="item.rejectNum" placeholder="" />
  113. <view v-else class="number value" style="margin-left:16rpx;">{{ item.rejectNum }}</view>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 拍照上传部分 -->
  118. <view class="title unfit-title uni-row">
  119. <text>拍照上传</text>
  120. </view>
  121. <view class=" uni-row" style="padding: 24rpx;
  122. margin: 0 16rpx;
  123. background-color: #ffffff;
  124. border-radius: 12rpx;">
  125. <uni-file-picker v-model="photoList" :readonly="!editable()" return-type="array" :image-styles="imageStyles" @select="select" file-mediatype="image" class="my-files" @delete="handleDeletedPhoto" ></uni-file-picker>
  126. </view>
  127. <!-- 咨询部分 -->
  128. <view class="title">咨询</view>
  129. <view class="consultation-container uni-column">
  130. <view class="consultation-item-container" v-for="(item, index) in consultations" :key="index">
  131. <view class="question uni-column">
  132. <view class="label uni-row">
  133. <text>问题描述</text>
  134. <text :style="selectType(item)">{{item.consultDepartment == 0?'技术':'品管'}}
  135. {{ selectText(item) }}</text>
  136. </view>
  137. <view class="content">{{ item.content }}</view>
  138. </view>
  139. <!-- 不需要暂时注释 -->
  140. <!-- <view v-if="item.answer !== ''" class="answer"
  141. style="margin-top: 24rpx; padding-top: 24rpx; border-top: 1px dotted #aaaaaa;">
  142. <view class="label">回复</view>
  143. <view class="content">{{ item.answer }}</view>
  144. </view> -->
  145. </view>
  146. </view>
  147. <view class="title">快速关联</view>
  148. <view class="consultation-container ">
  149. <view class="title unfit-title uni-row">
  150. <view class="add-btn" style="background-color: #409eff;" @click="handleAddLot">关联批次</view>
  151. </view>
  152. <view >
  153. <zb-table
  154. :columns="relateColumn"
  155. :stripe="true"
  156. :fit="true"
  157. @dele="dele"
  158. :data="processInspecion.relateList"></zb-table>
  159. </view>
  160. </view>
  161. <!-- 报工部分 -->
  162. <view class="daywork-container">
  163. <!-- 此处后续要加上条件限制,当状态为合格或不合格的时候不能修改状态,需要有权限的人来进行修改 -->
  164. <!-- <view class="result uni-row">
  165. <view class="label">检测量</view>
  166. <input type="number" v-model="processInspecion.examiningNum" placeholder="请输入检测量" />
  167. <view class="label" style="text-align: right; padding-right: 24rpx">废品量</view>
  168. <input type="number" v-model="processInspecion.rejectNum" placeholder="请输入废品量" />
  169. </view> -->
  170. <view class="result resu uni-row" style="margin-top: 20rpx;">
  171. <view class="label" style="width: 170rpx;">外协检状态</view>
  172. <uni-data-checkbox v-if="editable()" v-model="processInspecion.status" :localdata="range"></uni-data-checkbox>
  173. <view v-else class="value">{{ processInspecion.status == 1 ? '合格' : '不合格' }}
  174. </view>
  175. </view>
  176. <view v-if="editable()">
  177. <view v-if="showTransfer" class="list-title uni-row" style="margin-top: 16rpx;">
  178. <text class="label">是否移交仪器室</text><text>&nbsp;否</text>
  179. <switch class="switch" @change="switchChange" style="transform:scale(0.7);margin-top: -16rpx;"
  180. color="rgba(255,85,85,1)" />
  181. <text>是</text>
  182. </view>
  183. <view v-else class="list-title uni-row" style="margin-top: 16rpx;">
  184. <text class="label">已经移交给仪器室</text>
  185. </view>
  186. </view>
  187. <view class="result uni-row">
  188. <view class="label">废品总数</view>
  189. <view class="value" style="margin-left: 10px;">{{ processInspecion.rejectNum }}</view>
  190. </view>
  191. <view class="remark uni-row">
  192. <view class="label">备注</view>
  193. <textarea v-if="editable()" v-model="processInspecion.remark" />
  194. <view v-else class="value">{{ processInspecion.remark }}</view>
  195. </view>
  196. <view class="btns-container uni-row">
  197. <view v-if="editable()" class="finished-btn" @click="endWork">结束报工</view>
  198. <view v-if="editable()" class="question-btn uni-column" @click.stop="handleAddConsultation">
  199. <uni-icons type="headphones" size="24" />
  200. <text>咨询</text>
  201. </view>
  202. </view>
  203. </view>
  204. <dialog-inspectionChamber ref='selectInspectionChamber'
  205. @handleSelectInspectionChamber='handleSelectInspectionChamber'></dialog-inspectionChamber>
  206. </view>
  207. </template>
  208. <script setup>
  209. import {
  210. ref,
  211. onMounted,
  212. getCurrentInstance
  213. } from 'vue'
  214. import {
  215. onLoad,
  216. onReady,
  217. onUnload,
  218. onShow
  219. } from '@dcloudio/uni-app'
  220. import {
  221. store
  222. } from '@/store/index.js'
  223. import {
  224. saveOutsourcedInspecion,
  225. getInstrumentRoomInspection,
  226. selectOutsourcedInspecion,
  227. saveOutsourceInspectionWithRelate
  228. } from '@/api/business/processInspection.js'
  229. import {getURL} from '@/api/sys/user.js'
  230. const lot = ref({})
  231. const unfitInfos = ref([]) //废品信息
  232. const oldUnfitInfos = ref([])
  233. const isEventTriggered = ref(false); // 创建一个标志位
  234. // 创建一个引用来存储最后一次请求的时间戳
  235. const lastRequestTimestamp = ref(0);
  236. const selectInspectionChamber = ref(null)
  237. const consultations = ref([]) //咨询信息
  238. const flag = ref(false)
  239. const showTransfer = ref(true)
  240. const processInspecion = ref({
  241. remark: "",
  242. rejectNum: 0,
  243. examiningNum: 0,
  244. status: 0,
  245. })
  246. const urlList = JSON.parse(uni.getStorageSync('baseUrl'))
  247. const webHost = ref(urlList.baseUrl)
  248. const photoList = ref([])
  249. const selected = ref([]);
  250. const selectedPhotos = ref([])
  251. const imageStyles = {
  252. width:60,
  253. height:60
  254. }
  255. const relateColumn = [
  256. { name: 'lotCode', label: '批号',align:'center', width: 200},
  257. { name: 'carrierCode', label: '箱号',align:'center', width: 200 },
  258. { name: 'operation', type:'operation',label: '关联',align:'center',renders:[
  259. {
  260. name:'删除',
  261. type:'warn',
  262. func:"dele",
  263. class:"buttonOp"
  264. },
  265. ]},
  266. ]
  267. const initStatus = ref(0)
  268. function dele(ite,index) {
  269. if(ite.isMaster == 1){
  270. uni.showToast({
  271. icon: 'none',
  272. title: '主检查单,不可删除'
  273. })
  274. }else{
  275. processInspecion.value.relateList.splice(index, 1);
  276. }
  277. }
  278. const editable = () => {
  279. if (processInspecion.value.auditStatus == 1) {
  280. return false
  281. }
  282. if (store.userInfo.permissions.some(item => item === 'business:outsourcedInspection:edit')) {
  283. return true
  284. }
  285. if (initStatus.value == 0) {
  286. return true
  287. }
  288. if (processInspecion.value.firstUpdaterId == store.userInfo.userId) {
  289. return true
  290. }
  291. return false
  292. }
  293. const consul = [{
  294. value: 0,
  295. text: "待确认",
  296. type: "color: #fcab53"
  297. }, {
  298. value: 2,
  299. text: "合格",
  300. type: "color: #55ff7f"
  301. }, {
  302. value: 1,
  303. text: "不合格",
  304. type: "color: #ff0c2c"
  305. }]
  306. const range = [{
  307. value: 0,
  308. text: "待确认",
  309. type: "color: #fcab53"
  310. }, {
  311. value: 1,
  312. text: "合格",
  313. type: "color: #55ff7f"
  314. }, {
  315. value: 2,
  316. text: "不合格",
  317. type: "color: #ff0c2c"
  318. }]
  319. /***************************** 页面生命周期函数 *****************************/
  320. onMounted(() => {
  321. const instance = getCurrentInstance().proxy
  322. const eventChannel = instance.getOpenerEventChannel();
  323. eventChannel.on('outsourcedInspectionFrom', function(data) {
  324. console.log('outsourcedInspectionFrom', data)
  325. if (data && data.data) {
  326. processInspecion.value.lot = data.data;
  327. }
  328. })
  329. })
  330. onLoad(() => {
  331. uni.$off('addWasteInfoEvent');
  332. if (!flag.value) {
  333. if (store.processInspection != null) {
  334. uni.showLoading({
  335. title: '加载中'
  336. });
  337. processInspecion.value = store.processInspection
  338. selectOutsourcedInspecion(processInspecion.value).then(res => {
  339. console.log("res", res);
  340. if (res.code == 200) {
  341. processInspecion.value = res.data;
  342. initStatus.value = res.data.status
  343. unfitInfos.value = res.data.rejects;
  344. oldUnfitInfos.value = res.data.oldRejects;
  345. consultations.value = res.data.dayworkItemConsults;
  346. selectedPhotos.value = res.data.processInspectionPictureList
  347. photoList.value = res.data.processInspectionPictureList.map(item => {
  348. return { ...item, url: webHost.value + item.url };
  349. });
  350. console.log("res", res);
  351. //判断是否移交到了仪器室
  352. getInstrumentRoomInspectionList()
  353. uni.hideLoading();
  354. // getInspecion();
  355. } else {
  356. uni.showToast({
  357. icon: 'none',
  358. title: res.msg,
  359. duration: 2000
  360. })
  361. }
  362. });
  363. }
  364. }
  365. })
  366. /***************************** 定义了一些方法 *****************************/
  367. //咨询文本
  368. function selectText(item) {
  369. for (var i = 0; i < consul.length; i++) {
  370. if (item.status == consul[i].value) {
  371. return consul[i].text
  372. }
  373. }
  374. }
  375. function upLoadImageHandler(arg) {
  376. getURL(arg).then(res =>{
  377. let data = JSON.parse(res)
  378. selectedPhotos.value.push({
  379. url:data.fileName,
  380. pictureName:data.originalFilename
  381. })
  382. console.log(selectedPhotos.value)
  383. })
  384. }
  385. function select (e) {
  386. console.log(e)
  387. const {
  388. tempFilePaths,
  389. tempFiles
  390. } = e
  391. tempFiles.forEach((item,index)=>{
  392. upLoadImageHandler({ filePath: tempFilePaths[index],name:item.name})
  393. })
  394. }
  395. function handleDeletedPhoto(e) {
  396. let fileName = selectedPhotos.value.map(info => info.pictureName)
  397. const firstSlashIndex = e.tempFile.url.lastIndexOf('/');
  398. const lastSlashIndex = e.tempFile.url.lastIndexOf('_');
  399. const type = e.tempFile.url.substring(firstSlashIndex + 1,lastSlashIndex)
  400. const pictureName = e.tempFile.url.substring(firstSlashIndex + 1,lastSlashIndex) +e.tempFile.url.substring(e.tempFile.url.lastIndexOf('.') -1 + 1);;
  401. let index = -1; // 初始化 index 为 -1,表示未找到
  402. // 首先检查 e.tempFile.name 是否存在
  403. if (fileName.findIndex(name => name === e.tempFile.name) !== -1) {
  404. index = fileName.findIndex(name => name === e.tempFile.name);
  405. }
  406. // 如果 e.tempFile.name 不存在,检查 e.tempFile.pictureName 是否存在
  407. else if (fileName.findIndex(name => name === e.tempFile.pictureName) !== -1) {
  408. index = fileName.findIndex(name => name === e.tempFile.pictureName);
  409. }
  410. // 如果以上两个都不存在,检查 pictureName 是否存在
  411. else if (fileName.findIndex(name => name === pictureName) !== -1) {
  412. index = fileName.findIndex(name => name === pictureName);
  413. }
  414. selectedPhotos.value.splice(index,1)
  415. }
  416. //打开电子图纸
  417. function handleDrawingMenu() {
  418. var outsourceOrderDetailId = encodeURIComponent(processInspecion.value.outsourceOrderDetailId);
  419. var lotCode = encodeURIComponent(processInspecion.value.lot.lotCode);
  420. var technologyVersion = encodeURIComponent(processInspecion.value.lot.technologyVersion)
  421. // 构建查询参数字符串
  422. var queryParam =
  423. `param1=${outsourceOrderDetailId}&param2=${lotCode}&param3=${processInspecion.value.lot.productId}&param4=${technologyVersion}`;
  424. // 使用模板字符串构建完整的URL
  425. var navigateUrl = `/pages/outsourcedDrawingMenu/index?${queryParam}`;
  426. // 导航到指定页面
  427. uni.navigateTo({
  428. url: navigateUrl
  429. });
  430. }
  431. function getInstrumentRoomInspectionList() {
  432. getInstrumentRoomInspection(processInspecion.value).then(res => {
  433. if (res.data.length > 0) {
  434. showTransfer.value = false
  435. } else {
  436. showTransfer.value = true
  437. }
  438. })
  439. }
  440. function switchChange(event) {
  441. if (event.detail.value) {
  442. processInspecion.value.flag = true
  443. } else {
  444. processInspecion.value.flag = false
  445. }
  446. }
  447. const rejectNumberChange = () => {
  448. let sumReject = 0
  449. let sumDisqualificationNum = 0
  450. let sumExaminingNum = 0
  451. unfitInfos.value.forEach(v => {
  452. sumReject += (v.rejectNum != null ? Number(v.rejectNum) : 0)
  453. sumDisqualificationNum += (v.disqualificationNum != null ? Number(v.disqualificationNum) : 0)
  454. sumExaminingNum += (v.examiningNum != null ? Number(v.examiningNum) : 0)
  455. })
  456. processInspecion.value.rejectNum = sumReject
  457. processInspecion.value.disqualificationNum = sumDisqualificationNum
  458. processInspecion.value.examiningNum = sumExaminingNum
  459. console.log(processInspecion.value)
  460. }
  461. //查询咨询列表
  462. function getInspecion() {
  463. processInspecion.value = store.processInspection
  464. selectInspecion(processInspecion.value).then(res => {
  465. console.log("咨询", res);
  466. if (res.code == 200) {
  467. console.log("res", res);
  468. } else {
  469. uni.showToast({
  470. icon: 'none',
  471. title: res.msg,
  472. duration: 2000
  473. })
  474. }
  475. });
  476. }
  477. //结束报工按钮
  478. function endWork() {
  479. let unf = unfitInfos.value;
  480. for (var i = 0; i < unfitInfos.value.length; i++) {
  481. console.log("废品信息");
  482. // if (!unf[i].checkStandard && !unf[i].checkResult && !unf[i].rejectNum) {
  483. // uni.showToast({
  484. // icon: 'none',
  485. // title: "废品信息不能为空",
  486. // duration: 2000
  487. // })
  488. // return;
  489. // }
  490. if (unf[i].checkStandard == '' || unf[i].checkStandard == null) {
  491. uni.showToast({
  492. icon: 'none',
  493. title: "检查标准不能为空",
  494. duration: 2000
  495. })
  496. return;
  497. }
  498. // if (unf[i].checkResult == '' || unf[i].checkResult == null) {
  499. // uni.showToast({
  500. // icon: 'none',
  501. // title: "检查结果不能为空",
  502. // duration: 2000
  503. // })
  504. // return;
  505. // }
  506. if (unf[i].rejectNum == null) {
  507. uni.showToast({
  508. icon: 'none',
  509. title: "废品量不能为空",
  510. duration: 2000
  511. })
  512. return;
  513. }
  514. if (unf[i].rejectNum < 0 || unf[i].examiningNum < 0 || unf[i].disqualificationNum < 0) {
  515. uni.showToast({
  516. icon: 'none',
  517. title: '检查量,不良品量,废品量不能小于0',
  518. duration: 2000
  519. })
  520. return
  521. }
  522. if (unf[i].examiningNum > processInspecion.value.lot.pudName) {
  523. uni.showToast({
  524. icon: 'none',
  525. title: '检查量不能大于投产量'
  526. })
  527. return
  528. }
  529. }
  530. let sumReject = 0
  531. unfitInfos.value.forEach(v => {
  532. sumReject += Number(v.rejectNum)
  533. })
  534. if (processInspecion.value.rejectNum != sumReject) {
  535. uni.showToast({
  536. icon: 'none',
  537. title: "废品量与废品信息不一致",
  538. duration: 2000
  539. })
  540. return;
  541. }
  542. if (processInspecion.value.rejectNum > processInspecion.value.lot.pudName) {
  543. uni.showToast({
  544. icon: 'none',
  545. title: '废品量不能大于投产量'
  546. })
  547. return
  548. }
  549. if (processInspecion.value.disqualificationNum > processInspecion.value.lot.pudName) {
  550. uni.showToast({
  551. icon: 'none',
  552. title: '不良品量不能大于投产量'
  553. })
  554. return
  555. }
  556. save();
  557. }
  558. function save() {
  559. const currentTime = Date.now();
  560. // 检查是否已经过去了 2 秒
  561. if (currentTime - lastRequestTimestamp.value < 2000) {
  562. // 如果在 2 秒 内已经点击,那么不执行
  563. uni.showToast({
  564. icon: 'none',
  565. title: `请勿重复点击`,
  566. duration: 2000
  567. })
  568. return;
  569. }
  570. let pages = getCurrentPages();
  571. processInspecion.value.dayworkItemConsults = consultations.value;
  572. processInspecion.value.dayworkItemRejects = unfitInfos.value;
  573. processInspecion.value.user = store.userInfo;
  574. processInspecion.value.processInspectionPictureList = selectedPhotos.value
  575. if (processInspecion.value.flag) {
  576. //打开选择仪器室的弹窗
  577. selectInspectionChamber.value.open()
  578. console.log(processInspecion.value)
  579. } else {
  580. saveOutsourceInspectionWithRelate(processInspecion.value).then(res => {
  581. if (res.code == 200) {
  582. let index = 0;
  583. for (let i = 0; i < pages.length; i++) {
  584. if (pages[i].$page.fullPath == "/pages/outsourcedInspection/index") {
  585. index = pages.length - i - 1;
  586. }
  587. }
  588. console.log("index", index);
  589. uni.navigateBack({
  590. delta: index
  591. });
  592. } else {
  593. uni.showToast({
  594. icon: 'none',
  595. title: res.msg,
  596. duration: 2000
  597. })
  598. }
  599. });
  600. }
  601. }
  602. function handleSelectInspectionChamber(data) {
  603. processInspecion.value.inspectionChamberId = data
  604. console.log(processInspecion.value)
  605. saveOutsourcedInspecion(processInspecion.value).then(res => {
  606. if (res.code == 200) {
  607. let index = 0;
  608. let pages = getCurrentPages();
  609. for (let i = 0; i < pages.length; i++) {
  610. if (pages[i].$page.fullPath == "/pages/outsourcedInspection/index") {
  611. index = pages.length - i - 1;
  612. }
  613. }
  614. console.log("index", index);
  615. uni.navigateBack({
  616. delta: index
  617. });
  618. } else {
  619. uni.showToast({
  620. icon: 'none',
  621. title: res.msg,
  622. duration: 2000
  623. })
  624. }
  625. });
  626. }
  627. //咨询样式
  628. function selectType(item) {
  629. for (var i = 0; i < consul.length; i++) {
  630. if (item.status == consul[i].value) {
  631. return consul[i].type
  632. }
  633. }
  634. }
  635. // const addWasteInfo = (data) => {
  636. // const info = {
  637. // title: data.title,
  638. // checkStandard: data.standard
  639. // }
  640. // unfitInfos.value.push(info)
  641. // }
  642. const addConsultation = (data) => {
  643. console.log(data)
  644. let info = data
  645. info.forEach(item => {
  646. item.status = 0
  647. })
  648. consultations.value = consultations.value.concat(info)
  649. isEventTriggered.value = true; // 更新标志位状态
  650. }
  651. /***************************** 定义了一些事件 *****************************/
  652. // 添加不合格信息
  653. // const handleAddWaste = () => {
  654. // let info = {}
  655. // unfitInfos.value.push(info)
  656. // // 监听事件,暂时不用,后续会使用
  657. // // uni.$once('addWasteInfoEvent', (data) => {
  658. // // addWasteInfo(data)
  659. // // })
  660. // // uni.navigateTo({
  661. // // url: "/pages/processInspection/options"
  662. // // })
  663. // }
  664. const handleAddWaste = () => {
  665. flag.value = true
  666. // 监听事件,暂时不用,后续会使用
  667. uni.$once('addWasteInfoEvent', (data) => {
  668. addWasteInfo(data)
  669. })
  670. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  671. var enprocessId = encodeURIComponent(processInspecion.value.lot.processId);
  672. // 构建查询参数字符串
  673. var queryParam = `param1=${encodedId}&param2=${enprocessId}`;
  674. // 使用模板字符串构建完整的URL
  675. var navigateUrl = `/pages/outsourcedInspection/options?${queryParam}`;
  676. // 导航到指定页面
  677. uni.navigateTo({
  678. url: navigateUrl
  679. });
  680. }
  681. const addWasteInfo = (data) => {
  682. console.log(data, "55555555")
  683. flag.value = true
  684. var info = {
  685. inspectionStandardsId: data.id,
  686. checkStandard: data.standard
  687. }
  688. unfitInfos.value.push(info)
  689. console.log(data)
  690. }
  691. // 删除不合格信息
  692. const handleDelWaste = (index) => {
  693. uni.showModal({
  694. title: '提示',
  695. content: '确定删除该项?',
  696. success: function(res) {
  697. if (res.confirm) {
  698. unfitInfos.value.splice(index, 1)
  699. rejectNumberChange()
  700. } else if (res.cancel) {
  701. return
  702. }
  703. }
  704. })
  705. }
  706. const addRelate = (relates) => {
  707. processInspecion.value.relateList = relates
  708. }
  709. const handleAddLot = () => {
  710. console.log('添加关联')
  711. uni.$once('relateEvent', (data) => {
  712. if (!isEventTriggered.value) {
  713. // 如果事件尚未触发,则执行事件触发逻辑
  714. addRelate(data)
  715. }
  716. uni.$off('relateEvent')
  717. })
  718. uni.navigateTo({
  719. url: "/pages/outsourcedInspection/relate",
  720. success: (res) => {
  721. res.eventChannel.emit("outsourcedInspectionRelation",
  722. processInspecion.value
  723. )
  724. }
  725. })
  726. }
  727. // 咨询
  728. const handleAddConsultation = () => {
  729. isEventTriggered.value = false;
  730. // 监听事件
  731. uni.$once('wasteConsultationEvent', (data) => {
  732. if (!isEventTriggered.value) {
  733. // 如果事件尚未触发,则执行事件触发逻辑
  734. addConsultation(data)
  735. }
  736. uni.$off('wasteConsultationEvent')
  737. })
  738. uni.navigateTo({
  739. url: "/pages/outsourcedInspection/consultation",
  740. success: (res) => {
  741. // 通过eventChannel向被打开页面传送数据
  742. res.eventChannel.emit("outsourcedInspectionConsultation", {
  743. data: processInspecion.value.lot
  744. })
  745. }
  746. })
  747. }
  748. </script>
  749. <style lang="scss">
  750. .page-container {
  751. // height: 100%;
  752. background-color: #ececec;
  753. font-size: 28rpx;
  754. >.title {
  755. font-weight: 700;
  756. margin: 24rpx 16rpx;
  757. }
  758. }
  759. .carrier-info {
  760. margin: 32rpx 16rpx 0 16rpx;
  761. padding: 24rpx;
  762. background-color: #ffffff;
  763. border-radius: 8rpx;
  764. .carrier-code {
  765. font-size: 32rpx;
  766. font-weight: 700;
  767. }
  768. .info-row {
  769. margin-top: 16rpx;
  770. color: #767676;
  771. .label {
  772. width: 160rpx;
  773. }
  774. .drawing-btn {
  775. padding: 12rpx 32rpx;
  776. background-color: #0055ff;
  777. color: #ffffff;
  778. border-radius: 12rpx;
  779. margin-left: auto;
  780. font-size: 28rpx;
  781. }
  782. .value {
  783. flex: 1;
  784. textarea {
  785. flex: 1;
  786. border: 1px solid #888888;
  787. box-sizing: border-box;
  788. padding: 16rpx;
  789. }
  790. }
  791. }
  792. }
  793. .unfit-title {
  794. margin-bottom: 24rpx;
  795. justify-content: space-between;
  796. align-items: center;
  797. text {
  798. font-size: 28rpx;
  799. font-weight: 700;
  800. }
  801. .add-btn {
  802. margin-right: 26rpx;
  803. padding: 12rpx 32rpx;
  804. background-color: #a4adb3;
  805. color: #ffffff;
  806. border-radius: 12rpx;
  807. font-size: 24rpx;
  808. }
  809. }
  810. .unfit-container {
  811. padding: 24rpx;
  812. margin: 0 16rpx;
  813. background-color: #ffffff;
  814. border-radius: 12rpx;
  815. .unfit-item-container {
  816. position: relative;
  817. >* {
  818. margin-bottom: 24rpx;
  819. }
  820. .title {
  821. font-weight: 700;
  822. justify-content: space-between;
  823. align-items: center;
  824. image {
  825. width: 40rpx;
  826. height: 40rpx;
  827. }
  828. }
  829. .standard {}
  830. .resu {
  831. width: 100%;
  832. align-items: center;
  833. input {
  834. margin-left: 20rpx;
  835. width: 200rpx;
  836. height: 56rpx;
  837. flex: 1;
  838. border: 1px solid #9f9f9f;
  839. font-size: 28rpx;
  840. }
  841. .label {
  842. width: 160rpx;
  843. }
  844. .value {
  845. flex: 1;
  846. textarea {
  847. flex: 1;
  848. border: 1px solid #888888;
  849. box-sizing: border-box;
  850. padding: 16rpx;
  851. }
  852. }
  853. }
  854. .result {
  855. border-bottom: 1px solid #9f9f9f;
  856. padding-bottom: 32rpx;
  857. align-items: center;
  858. .label {
  859. width: 160rpx;
  860. }
  861. .value {
  862. flex: 1;
  863. textarea {
  864. flex: 1;
  865. border: 1px solid #888888;
  866. box-sizing: border-box;
  867. padding: 16rpx;
  868. }
  869. }
  870. input {
  871. width: 280rpx;
  872. height: 56rpx;
  873. border: 1px solid #9f9f9f;
  874. font-size: 28rpx;
  875. &.number {
  876. width: 104rpx;
  877. text-align: center;
  878. }
  879. }
  880. }
  881. }
  882. .unfit-item-container:last-child {
  883. .result {
  884. border-bottom: none;
  885. padding-bottom: 0;
  886. }
  887. }
  888. }
  889. .consultation-container {
  890. margin: 0 16rpx;
  891. padding: 24rpx;
  892. background-color: #ffffff;
  893. border-radius: 8rpx;
  894. .consultation-item-container {
  895. margin-bottom: 24rpx;
  896. border-bottom: 2px solid #888888;
  897. padding-bottom: 24rpx;
  898. }
  899. .consultation-item-container:last-child {
  900. margin-bottom: 0;
  901. border-bottom: 0;
  902. padding-bottom: 0;
  903. }
  904. .question,
  905. .answer {
  906. .label {
  907. justify-content: space-between;
  908. margin-bottom: 16rpx;
  909. font-weight: 700;
  910. }
  911. .content {
  912. line-height: 40rpx;
  913. }
  914. }
  915. .answer {
  916. margin-top: 24rpx;
  917. }
  918. }
  919. .daywork-container {
  920. margin-top: 24rpx;
  921. padding: 24rpx;
  922. background-color: #ffffff;
  923. border: 1px solid #bcbcbc;
  924. .result {
  925. align-items: center;
  926. .label {
  927. width: 112rpx;
  928. }
  929. input {
  930. flex: 1;
  931. height: 56rpx;
  932. border: 1px solid #9f9f9f;
  933. font-size: 28rpx;
  934. text-align: center;
  935. }
  936. }
  937. .remark {
  938. margin-top: 24rpx;
  939. .label {
  940. width: 112rpx;
  941. }
  942. textarea {
  943. flex: 1;
  944. border: 1px solid #9f9f9f;
  945. height: 168rpx;
  946. }
  947. }
  948. .btns-container {
  949. margin-top: 24rpx;
  950. .finished-btn {
  951. display: flex;
  952. flex: 1;
  953. height: 80rpx;
  954. background-color: #fc6565;
  955. color: #ffffff;
  956. text-align: center;
  957. justify-content: center;
  958. align-items: center;
  959. border-radius: 8rpx;
  960. }
  961. .question-btn {
  962. width: 80rpx;
  963. align-items: flex-end;
  964. image {
  965. width: 48rpx;
  966. height: 48rpx;
  967. }
  968. text {
  969. font-size: 24rpx;
  970. }
  971. }
  972. }
  973. }
  974. .uni-input-input:disabled {
  975. background-color: #f5f7fa;
  976. }
  977. .my-files {
  978. display: flex;
  979. justify-content: center;
  980. :deep(.uni-file-picker__container) {
  981. flex-direction: row;
  982. }
  983. }
  984. .consultation-container {
  985. margin: 0 16rpx;
  986. padding: 24rpx;
  987. background-color: #ffffff;
  988. border-radius: 8rpx;
  989. .consultation-item-container {
  990. margin-bottom: 24rpx;
  991. border-bottom: 2px solid #888888;
  992. padding-bottom: 24rpx;
  993. }
  994. .consultation-item-container:last-child {
  995. margin-bottom: 0;
  996. border-bottom: 0;
  997. padding-bottom: 0;
  998. }
  999. .question,
  1000. .answer {
  1001. .label {
  1002. justify-content: space-between;
  1003. margin-bottom: 16rpx;
  1004. font-weight: 700;
  1005. }
  1006. .content {
  1007. line-height: 40rpx;
  1008. }
  1009. }
  1010. .answer {
  1011. margin-top: 24rpx;
  1012. }
  1013. }
  1014. .zb-table .item-tr {
  1015. flex-direction: row;
  1016. }
  1017. </style>