sampleConfirmationJS.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. import repostCurd from '@/business/platform/form/utils/custom/joinCURD.js'
  2. import * as dayjs from 'dayjs'
  3. const options = {
  4. '一个月': 1,
  5. '两个月': 2,
  6. '三个月': 3,
  7. '四个月': 4,
  8. '半年': 6,
  9. '九个月': 9,
  10. '一年': 12
  11. }
  12. export default {
  13. methods: {
  14. /* 唤醒扫码 前端脚本直接调用*/
  15. openRedar(type) {
  16. this.redar = true // 扫码图标显示
  17. this.visible = false // 结果列表,一开始为false
  18. this.$refs.redarInput.focus(); // 聚焦input
  19. this.listData = [] // 清空列表
  20. },
  21. facilityData(id) {
  22. if (!id) return // 无参直接反
  23. this.loadData(id)
  24. //开始查询设备
  25. this.facilityId = ''
  26. },
  27. /* 获取数据 ,开始查阅记录 */
  28. loadData(id) {
  29. // let this_ = this
  30. let flag = true // 重复扫码标志位
  31. for (let index in this.listData) { // 判断是否重复,重复扫码 数量自增
  32. if (this.listData[index].yang_pin_bian_hao == id) {
  33. this.listData[index].jie_yang_shu_lian = parseInt(this.listData[index].jie_yang_shu_lian) + 1
  34. flag = false
  35. }
  36. }
  37. // 扫码扫到新数据,查询 回填展示
  38. if (flag) {
  39. let sql = `select ypb.*,sqb.chu_ju_bao_gao_ya from t_lhypb ypb join t_lhwtsqb sqb on ypb.parent_id_ = sqb.id_ and find_in_set(ypb.yang_pin_bian_hao,'${id}') and ypb.jie_yang_zhuang_t = '待接收' and ypb.shi_fou_guo_shen_ = '1'`
  40. let liuYangSQL = `select liu_yang_qi_xian_ from t_lyqxpzb limit 1`
  41. Promise.all([repostCurd('sql', sql), repostCurd('sql', liuYangSQL)]).then((res) => {
  42. let temp = res[0].variables.data
  43. let option = res[1].variables.data[0].liu_yang_qi_xian_
  44. let rq = options[option]
  45. if (temp) {
  46. temp.forEach(item => {
  47. item.jie_yang_shu_lian = item.yang_pin_zong_shu
  48. item.jie_yang_zhuang_t = '已确认'
  49. item.biao_zhi_uuid_1 = this.uuid()
  50. item.biao_zhi_uuid_2 = this.uuid()
  51. item.biao_zhi_uuid_3 = this.uuid()
  52. item.biao_zhi_uuid_4 = this.uuid()
  53. item.shi_fou_liu_yang_ = '是'
  54. item.yan_shou_jie_guo_ = '完好'
  55. item.liu_yang_shu_lian_yi = ' ml/支×1支'
  56. item.yang_pin_lei_er_ ? item.liu_yang_shu_lian_er = ' ml/支×1支' : null
  57. item.yang_pin_lei_san_ ? item.liu_yang_shu_lian_san = ' ml/支×1支' : null
  58. item.yang_pin_lei_si_ ? item.liu_yang_shu_lian_si = ' ml/支×1支' : null
  59. item.liu_yang_ri_qi_ = new Date(new Date().getTime() + 28800000).toJSON().slice(0, 10).replace('T', ' ')
  60. item.yang_pin_lei_er_ ? this.$set(item, 'flag2', true) : this.$set(item, 'flag2', false)
  61. item.yang_pin_lei_san_ ? this.$set(item, 'flag3', true) : this.$set(item, 'flag3', false)
  62. item.yang_pin_lei_si_ ? this.$set(item, 'flag4', true) : this.$set(item, 'flag4', false)
  63. item.liu_yang_qi_xian = dayjs(item.song_jian_shi_jia).add(rq, 'month').format("YYYY-MM-DD")
  64. })
  65. this.listData.push(temp[0])
  66. // console.log(this.listData)
  67. }
  68. })
  69. }
  70. },
  71. /* 列表失去焦点*/
  72. handleChange() {
  73. this.$refs.redarInput.focus(); //聚焦input
  74. },
  75. /* 关闭弹出列表框*/
  76. closeDialog() {
  77. this.remRedar()
  78. //回传关闭事件。隐藏当前组件。
  79. },
  80. handleClose() {
  81. this.handleChange()
  82. this.$confirm('确认关闭扫码列表页面?').then(_ => {
  83. this.closeDialog();
  84. }).catch(_ => {});
  85. },
  86. handleAnySituation(callBackBool,msg,type){
  87. this.$emit('callback', callBackBool)
  88. this.visable = false
  89. this.$message({
  90. message: msg,
  91. type: type
  92. })
  93. this.closeDialog();
  94. },
  95. submitData(type) {
  96. // this指针
  97. let this_ = this;
  98. // 回传关闭事件。隐藏当前组件。
  99. let judge = true;
  100. if (this_.listData.length == 0) {
  101. this.$emit('callback', true)
  102. this.visable = false
  103. this.$message({
  104. message: '暂无样品待接收确认!',
  105. type: 'error'
  106. })
  107. this.closeDialog();
  108. } else {
  109. this.$confirm('请再次确认 [样品接收信息]').then(_ => {
  110. // 获取样品列表
  111. let ypInfoList = this_.listData
  112. // console.log(ypInfoList, "样品信息")
  113. let dWhere = []
  114. let ypbh = []
  115. let ypbhList = [] // 样品编号列表
  116. // 罗湖样品编号列表
  117. let lhypbhList = []
  118. let lhypmcList = []
  119. // 罗湖样品表外键
  120. let lhypbWJ = []
  121. // 罗湖委托表主键
  122. let lhwtbID = []
  123. // 罗湖委托表展示表ID
  124. let lhwtzsbID = []
  125. // 罗湖样品id列表
  126. let lhypIdList = []
  127. // 罗湖样品id格式列表
  128. let lhypIdNewList = []
  129. // 样品所选择的位置ID字符串
  130. let localStr = ''
  131. let locationIds = new Set()
  132. let localArr = []
  133. for (let yp in ypInfoList) { //样品数据
  134. let cfwz = ''
  135. /*
  136. 校验:
  137. 1、样品数量 <= 确认数量
  138. 2、是否留样 => 填收样位置|留样位置
  139. 3、验收结果必填
  140. 4、如果留样 => 必填项:留样日期、留样数量、留样期限至、销毁日期
  141. */
  142. if (ypInfoList[yp].jie_yang_shu_lian > ypInfoList[yp].yang_pin_zong_shu) {
  143. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 接收确认数量不得大于收样数量。')
  144. return;
  145. }
  146. if (ypInfoList[yp].jie_yang_zhuang_t == '未确认') {
  147. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 接收确认状态必须为已确认。')
  148. return;
  149. }
  150. if (ypInfoList[yp].yan_shou_jie_guo_ == null || ypInfoList[yp].yan_shou_jie_guo_ == '') {
  151. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 验收结果不能为空!')
  152. return;
  153. }
  154. if (ypInfoList[yp].shi_fou_liu_yang_ == null || ypInfoList[yp].shi_fou_liu_yang_ == '') {
  155. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 是否留样不能为空!')
  156. return;
  157. }
  158. if (ypInfoList[yp].shi_fou_liu_yang_ == "是") {
  159. if (ypInfoList[yp].liu_yang_ri_qi_ == null || ypInfoList[yp].liu_yang_ri_qi_ == '') {
  160. this_.$message.error("留样时必须填写留样日期!")
  161. return;
  162. }
  163. }
  164. // 判断位置是否为空
  165. if (ypInfoList[yp].shou_yang_wei_zhi_yi == null || ypInfoList[yp].shou_yang_wei_zhi_yi == ''
  166. || ypInfoList[yp].liu_yang_wei_zhi_yi == null || ypInfoList[yp].liu_yang_wei_zhi_yi == '') {
  167. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 类型1的位置选择不能为空!')
  168. return;
  169. }
  170. if (ypInfoList[yp].flag2 == true && (ypInfoList[yp].shou_yang_wei_zhi_er == '' || ypInfoList[yp].shou_yang_wei_zhi_er == null || ypInfoList[yp].liu_yang_wei_zhi_er == '' || ypInfoList[yp].liu_yang_wei_zhi_er == null)) {
  171. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 类型2的位置选择不能为空!')
  172. return;
  173. }
  174. if (ypInfoList[yp].flag3 == true && (ypInfoList[yp].shou_yang_wei_zhi_san == '' || ypInfoList[yp].shou_yang_wei_zhi_san == null || ypInfoList[yp].liu_yang_wei_zhi_san == '' || ypInfoList[yp].liu_yang_wei_zhi_san == null)) {
  175. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 类型3的位置选择不能为空!')
  176. return;
  177. }
  178. if (ypInfoList[yp].flag4 == true && (ypInfoList[yp].shou_yang_wei_zhi_si == '' || ypInfoList[yp].shou_yang_wei_zhi_si == null || ypInfoList[yp].liu_yang_wei_zhi_si == '' || ypInfoList[yp].liu_yang_wei_zhi_si == null)) {
  179. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 类型4的位置选择不能为空!')
  180. return;
  181. }
  182. ypbhList.push('{"yang_pin_bian_hao":"' + ypInfoList[yp].yang_pin_bian_hao + '"}') // 样品编号列表
  183. // 罗湖
  184. dWhere.push('{"id_":"' + cfwz + '"}')
  185. lhypbhList.push(ypInfoList[yp].yang_pin_bian_hao)
  186. lhypbWJ.push(ypInfoList[yp].parent_id_)
  187. lhypIdList.push(ypInfoList[yp].id_)
  188. lhypIdNewList.push('{"id_":"' + ypInfoList[yp].id_ + '"}')
  189. ypbh.push(ypInfoList[yp].yang_pin_bian_hao)
  190. lhypmcList.push(ypInfoList[yp].yang_pin_ming_che)
  191. localArr.push(
  192. ypInfoList[yp].shou_yang_wei_zhi_yi, ypInfoList[yp].liu_yang_wei_zhi_yi,
  193. ypInfoList[yp].shou_yang_wei_zhi_er, ypInfoList[yp].liu_yang_wei_zhi_er,
  194. ypInfoList[yp].shou_yang_wei_zhi_san, ypInfoList[yp].liu_yang_wei_zhi_san,
  195. ypInfoList[yp].shou_yang_wei_zhi_si, ypInfoList[yp].liu_yang_wei_zhi_si
  196. )
  197. }
  198. localStr = localArr.filter(i => i).join(',')
  199. let value = ''
  200. let lhypIdStr = ''
  201. for (let i = 0; i < lhypbWJ.length; i++) {
  202. value += lhypbWJ[i] + ','
  203. }
  204. value = value.substring(0, value.length - 1)
  205. value = value.replace(/,/g, "','")
  206. for (let i = 0; i < lhypIdList.length; i++) {
  207. lhypIdStr += lhypIdList[i] + ','
  208. }
  209. lhypIdStr = lhypIdStr.substring(0, lhypIdStr.length - 1)
  210. lhypIdStr = lhypIdStr.replace(/,/g, "','")
  211. let currentTime = new Date(new Date().getTime() + 28800000).toJSON().slice(0, 16).replace('T', ' ')
  212. let allSQL = `select a.id_ as wtID,a.chu_ju_bao_gao_ya,a.zhan_shi_biao_id_,a.wei_tuo_lei_xing_,a.he_tong_id_,a.bao_gao_lei_xing_,a.wei_tuo_bian_hao_, a.wei_tuo_dan_wei_ as wtdh, a.wei_tuo_fang_lian, a.wei_tuo_lian,a.bao_gao_bian_zhi_,a.bao_gao_fu_he_yua,b.* from t_lhwtsqb a inner join t_lhypb b on a.id_ = b.parent_id_ where b.parent_id_ in ('${value}')and b.id_ in ('${lhypIdStr}')`
  213. // 搜集所有选择的位置信息
  214. // console.log('当前选择的位置ids:',locationIds)
  215. var allLocal = `select * from t_ypcfwz where find_in_set(id_,'${localStr}')`
  216. Promise.all([repostCurd("sql", allSQL), repostCurd("sql", allLocal)]).then((res) => {
  217. let result = res[0].variables.data
  218. let localInfo = res[1].variables.data
  219. // todo
  220. // console.log(localInfo)
  221. /* 1、更新货架位置信息 */
  222. this.emptyLocal = []
  223. this.fullLocal = []
  224. let allUUID = []
  225. ypInfoList.forEach(item => {
  226. allUUID.push(item.biao_zhi_uuid_1, item.biao_zhi_uuid_2, item.biao_zhi_uuid_3, item.biao_zhi_uuid_4)
  227. let allResult = []
  228. allResult.push(this.handleLocationInfo(item.shou_yang_wei_zhi_yi, '否', localInfo, locationIds, item, item.biao_zhi_uuid_1, currentTime))
  229. if (item.shou_yang_wei_zhi_er != undefined) {
  230. allResult.push(this.handleLocationInfo(item.shou_yang_wei_zhi_er, '否', localInfo, locationIds, item, item.biao_zhi_uuid_2, currentTime))
  231. }
  232. if (item.shou_yang_wei_zhi_san != undefined) {
  233. allResult.push(this.handleLocationInfo(item.shou_yang_wei_zhi_san, '否', localInfo, locationIds, item, item.biao_zhi_uuid_3, currentTime))
  234. }
  235. if (item.shou_yang_wei_zhi_si != undefined) {
  236. allResult.push(this.handleLocationInfo(item.shou_yang_wei_zhi_si, '否', localInfo, locationIds, item, item.biao_zhi_uuid_4, currentTime))
  237. }
  238. allResult.push(this.handleLocationInfo(item.liu_yang_wei_zhi_yi, '是', localInfo, locationIds, item, item.biao_zhi_uuid_1, currentTime))
  239. if (item.liu_yang_wei_zhi_er != undefined) {
  240. allResult.push(this.handleLocationInfo(item.liu_yang_wei_zhi_er, '是', localInfo, locationIds, item, item.biao_zhi_uuid_2, currentTime))
  241. }
  242. if (item.liu_yang_wei_zhi_san != undefined) {
  243. allResult.push(this.handleLocationInfo(item.liu_yang_wei_zhi_san, '是', localInfo, locationIds, item, item.biao_zhi_uuid_3, currentTime))
  244. }
  245. if (item.liu_yang_wei_zhi_si != undefined) {
  246. allResult.push(this.handleLocationInfo(item.liu_yang_wei_zhi_si, '是', localInfo, locationIds, item, item.biao_zhi_uuid_4, currentTime))
  247. }
  248. allResult.forEach(item => {
  249. item.name === 'emptyLocation' ? this.emptyLocal.push(item.value) : this.fullLocal.push(item.value)
  250. })
  251. })
  252. let allUUIDStr = allUUID.filter(i => i).join(',')
  253. // console.log(allUUIDStr)
  254. // 更新样品位置list
  255. // console.log('emptyLocal:',this.emptyLocal)
  256. let allParams = {
  257. tableName: 't_ypcfwz',
  258. updList: this.emptyLocal
  259. }
  260. repostCurd('updatesByWhere', JSON.stringify(allParams))
  261. // 插入样品位置list
  262. // console.log('fullLocal:',this.fullLocal)
  263. repostCurd('add', '{"tableName":"t_ypcfwz","paramWhere":' + JSON.stringify(this.fullLocal) + '}').then(res => {
  264. // 再次查询位置表,对比当前样品列表 替换初始值为占用的样品位置id
  265. let findLocationAgain = `select id_,shi_fou_liu_yang_,biao_zhi_uuid_ from t_ypcfwz where find_in_set(biao_zhi_uuid_,'${allUUIDStr}')`
  266. // console.log(findLocationAgain)
  267. repostCurd('sql', findLocationAgain).then(res => {
  268. let data = res.variables.data
  269. let uuidArgs = ['biao_zhi_uuid_1', 'biao_zhi_uuid_2', 'biao_zhi_uuid_3', 'biao_zhi_uuid_4']
  270. let shouYangArgs = ['shou_yang_wei_zhi_yi', 'shou_yang_wei_zhi_er', 'shou_yang_wei_zhi_san', 'shou_yang_wei_zhi_si']
  271. let liuYangArgs = ['liu_yang_wei_zhi_yi', 'liu_yang_wei_zhi_er', 'liu_yang_wei_zhi_san', 'liu_yang_wei_zhi_si']
  272. data.forEach(item => {
  273. uuidArgs.forEach((uuid, index) => {
  274. let ypIndex = ypInfoList.findIndex(i => i[uuid] === item.biao_zhi_uuid_)
  275. if (ypIndex != -1) {
  276. item.shi_fou_liu_yang_ === '否' ?
  277. ypInfoList[ypIndex][shouYangArgs[index]] = item.id_ :
  278. ypInfoList[ypIndex][liuYangArgs[index]] = item.id_
  279. }
  280. })
  281. })
  282. // repostCurd('updates', '{"tableName":"t_lhypb","paramWhere":[' + lhypIdNewList + '],"paramCond":{"jie_yang_zhuang_t":"已接收"}}')
  283. /* 2、封装样品登记表对象,插入样品登记表 顺便封装任务分配表 */
  284. let ypdjb = []
  285. let rws = []
  286. result.forEach((item, index) => {
  287. // 2-1:统计每个样品有多少类型[数量]
  288. let lxList = []
  289. let ypggList = []
  290. let liuYangList = []
  291. lxList.push(item.yang_pin_lei_xing, item.yang_pin_lei_er_, item.yang_pin_lei_san_, item.yang_pin_lei_si_)
  292. ypggList.push(item.yang_pin_gui_ge_, item.yang_pin_gui_ge_e, item.yang_pin_gui_ge_s, item.yang_pin_gui_si_)
  293. liuYangList.push(ypInfoList[index].liu_yang_shu_lian_yi, ypInfoList[index].liu_yang_shu_lian_er, ypInfoList[index].liu_yang_shu_lian_san, ypInfoList[index].liu_yang_shu_lian_si)
  294. let yplxz = lxList.filter(i => i).join(',')
  295. let ypggStr = ypggList.filter(i => i).join(',')
  296. let liuyangStr = liuYangList.filter(i => i).join(',')
  297. // let count = lxList.filter(i => i).join(',').match(/,/g).length + 1
  298. let size = lxList.filter(i => i).join(',').match(/,/g)
  299. let count = 1
  300. size == null ? count = 1 : count = size.length + 1
  301. for (let c = 0; c < count; c++) {
  302. let xmmc = []
  303. xmmc.push(item.chang_gui_xiang_m, item.tao_can_ming_chen)
  304. let xiangMuZh = xmmc.filter(i => i).join(',')
  305. let yblx = c == 0 ? item.yang_pin_lei_xing : c == 1 ? item.yang_pin_lei_er_ : c == 2 ? item.yang_pin_lei_san_ : c == 3 ? item.yang_pin_lei_si_ : ''
  306. let ystj = c == 0 ? item.yang_ben_yun_shu_ : c == 1 ? item.yang_pin_yun_shu_ : c == 2 ? item.yang_pin_yun_san : c == 3 ? item.yang_pin_yun_si_ : ''
  307. let ypsl = c == 0 ? item.shu_liang_ : c == 1 ? item.shu_liang_er_ : c == 2 ? item.shu_liang_san_ : c == 3 ? item.shu_liang_si_ : ''
  308. let ybgg = c == 0 ? item.yang_pin_gui_ge_ : c == 1 ? item.yang_pin_gui_ge_e : c == 2 ? item.yang_pin_gui_ge_s : c == 3 ? item.yang_pin_gui_si_ : ''
  309. let sywz = c == 0 ? ypInfoList[index].shou_yang_wei_zhi_yi : c == 1 ? ypInfoList[index].shou_yang_wei_zhi_er : c == 2 ? ypInfoList[index].shou_yang_wei_zhi_san : c == 3 ? ypInfoList[index].shou_yang_wei_zhi_si : ''
  310. let lycf = c == 0 ? ypInfoList[index].liu_yang_wei_zhi_yi : c == 1 ? ypInfoList[index].liu_yang_wei_zhi_er : c == 2 ? ypInfoList[index].liu_yang_wei_zhi_san : c == 3 ? ypInfoList[index].liu_yang_wei_zhi_si : ''
  311. let lysl = c == 0 ? ypInfoList[index].liu_yang_shu_lian_yi : c == 1 ? ypInfoList[index].liu_yang_shu_lian_er : c == 2 ? ypInfoList[index].liu_yang_shu_lian_san : c == 3 ? ypInfoList[index].liu_yang_shu_lian_si : ''
  312. let currentUUID = c == 0 ? ypInfoList[index].biao_zhi_uuid_1 : c == 1 ? ypInfoList[index].biao_zhi_uuid_2 : c == 2 ? ypInfoList[index].biao_zhi_uuid_3 : c == 3 ? ypInfoList[index].biao_zhi_uuid_4 : ''
  313. let obj = {
  314. wei_tuo_dan_hao_: item.wei_tuo_bian_hao_,
  315. wei_tuo_dan_wei_: item.wtdh,
  316. lian_xi_ren_: item.wei_tuo_fang_lian,
  317. lian_xi_dian_hua_: item.wei_tuo_lian,
  318. yang_ben_ming_che: item.yang_pin_ming_che,
  319. yang_ben_bian_hao: item.yang_pin_bian_hao,
  320. pi_hao_bian_hao_: item.song_jian_pi_hao_,
  321. song_jian_dan_wei: item.song_jian_dan_wei,
  322. xing_ming_: ypInfoList[index].xing_ming_,
  323. xing_bie_: ypInfoList[index].xing_bie_,
  324. nian_ling_: ypInfoList[index].nian_ling_,
  325. yang_ben_zhuang_t: item.yang_pin_zhuang_t,
  326. shou_yang_ri_qi_: currentTime,
  327. bei_zhu_: ypInfoList[index].bei_zhu_,
  328. yang_ben_lei_xing: yblx,
  329. yun_shu_tiao_jian: ystj,
  330. yang_pin_shu_lian: ypsl,
  331. yang_ben_gui_ge_s: ybgg,
  332. yan_shou_jie_guo_: ypInfoList[index].yan_shou_jie_guo_,
  333. cun_fang_wei_zhi_: sywz,
  334. liu_zhuan_zhuang_: '待检',
  335. shi_fou_liu_yang_: ypInfoList[index].shi_fou_liu_yang_,
  336. liu_yang_ri_qi_: ypInfoList[index].liu_yang_ri_qi_,
  337. liu_yang_cun_fang: lycf,
  338. liu_yang_shu_lian: lysl,
  339. liu_yang_qi_xian: ypInfoList[index].liu_yang_qi_xian,
  340. xiao_hui_ri_qi_: ypInfoList[index].xiao_hui_ri_qi_,
  341. fan_yang_ri_qi_: ypInfoList[index].fan_yang_ri_qi_,
  342. fan_yang_jyr: ypInfoList[index].fan_yang_jyr,
  343. biao_zhi_uuid_: currentUUID,
  344. song_yang_yao_qiu: ypInfoList[index].song_yang_yao_qiu,
  345. jian_ce_xiang_mu_: xiangMuZh
  346. }
  347. ypdjb.push(obj)
  348. }
  349. // 2-2:封装任务分配表
  350. let rw = {
  351. yang_pin_ming_che: item.yang_pin_ming_che,
  352. yang_pin_bian_hao: item.yang_pin_bian_hao,
  353. wei_tuo_lei_xing_: item.wei_tuo_lei_xing_,
  354. yang_pin_lei_xing: yplxz,
  355. yang_pin_gui_ge_: ypggStr,
  356. wei_tuo_id_: item.wtID,
  357. he_tong_id_: item.he_tong_id_,
  358. zhuang_tai_: '待任务分配',
  359. wan_cheng_shi_jia: item.song_jian_shi_jia,
  360. bao_gao_lei_xing_: item.bao_gao_lei_xing_,
  361. xin_xiang_mu_ming: item.xiang_mu_ming_che,
  362. zhan_shi_biao_id_: item.zhan_shi_biao_id_,
  363. fen_zhuang_liu_ya: liuyangStr,
  364. shi_fou_jia_ji_: item.chu_ju_bao_gao_ya, // 是否加急【2023/2/23王嘎嘎提出】
  365. yang_pin_shu_lian: ypInfoList[index].jie_yang_shu_lian // 样品确认总数【2023/3/7王嘎嘎提出】
  366. }
  367. rws.push(rw)
  368. lhwtzsbID.push('{"shen_qing_id_":"' + item.zhan_shi_biao_id_ + '"}')
  369. lhwtbID.push('{"id_":"' + item.wtID + '"}')
  370. })
  371. /* 4、任务分配
  372. 4-1、根据 wtdAndYpb 的 wtID 更改委托表的 委托状态 wei_tuo_zhuang_ta 变成 已完成
  373. 4-2、根据每个样品一个任务分配流程 遍历样品表开任务分配流程
  374. 4-3、委托表找zhan_shi_biao_id_ 修改 t_lhwtzsb "zhuang_tai_"为"任务分配进行中"
  375. 优化:将其他不冲突的更改状态脚本放在任务分配后并行处理
  376. */
  377. // console.log("4、任务分配",rws)
  378. repostCurd('add', '{"tableName":"t_lhrwfpb","paramWhere":' + JSON.stringify(rws) + ',"defKey":"Process_04o0csc","formKey":"lhrwfp"}').then(res=>{
  379. // console.log('4、更改委托表的 委托状态',lhwtbID)
  380. repostCurd('updates', '{"tableName":"t_lhwtsqb","paramWhere":[' + lhwtbID + '],"paramCond":{"wei_tuo_zhuang_ta":"已完成"}}')
  381. /* 5、更新展示表 */
  382. if (lhwtzsbID.length > 0) {
  383. // console.log('5、更新展示表',lhwtzsbID)
  384. repostCurd('updates', '{"tableName":"t_lhwtzsb","paramWhere":[' + lhwtzsbID + '],"paramCond":{"zhuang_tai_":"任务分配进行中"}}')
  385. }
  386. console.log('样品登记表:',ypdjb)
  387. repostCurd('add', '{"tableName":"t_lhypdjb","paramWhere":' + JSON.stringify(ypdjb) + '}')
  388. /* 3、更新样品表 */
  389. // console.log('3、更新样品表',lhypIdNewList)
  390. repostCurd('updates', '{"tableName":"t_lhypb","paramWhere":[' + lhypIdNewList + '],"paramCond":{"jie_yang_zhuang_t":"已接收"}}').then(res=>{
  391. this.handleAnySituation(true,"样品成功接收,正在开启任务分配!",'success')
  392. })
  393. })
  394. })
  395. })
  396. })
  397. }).catch(_ => { });
  398. }
  399. },
  400. /* 去除指定行数据 使用过滤器filter过滤指定行号数据 */
  401. deleteData(val) {
  402. this.listData = this.listData.filter((data) => {
  403. return data.id_ != val
  404. })
  405. },
  406. uuid() {
  407. var s = [];
  408. var hexDigits = "0123456789abcdef";
  409. for (var i = 0; i < 36; i++) {
  410. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  411. }
  412. s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
  413. s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  414. s[8] = s[13] = s[18] = s[23] = "-";
  415. var uuid = s.join("");
  416. return uuid;
  417. },
  418. unique(arr) {
  419. return arr.filter((item, index) => {
  420. return arr.indexOf(item, 0) === index;
  421. });
  422. },
  423. // 根据旧位置数据生成新位置数据
  424. generateNewLocation(oldLocation, sampleInfo) {
  425. let temp = {
  426. fang_jian_lei_xin: oldLocation.fang_jian_lei_xin,
  427. wei_zhi_: oldLocation.wei_zhi_,
  428. qu_yu_: oldLocation.qu_yu_,
  429. huo_jia_lei_xing_: oldLocation.huo_jia_lei_xing_,
  430. huo_jia_hao_: oldLocation.huo_jia_hao_,
  431. ceng_hao_: oldLocation.ceng_hao_,
  432. shui_ping_fen_qu_: oldLocation.shui_ping_fen_qu_,
  433. wei_zhi_bian_hao_: oldLocation.wei_zhi_bian_hao_,
  434. wei_zhi_zhuang_ta: oldLocation.wei_zhi_zhuang_ta,
  435. cun_chu_tiao_jian: oldLocation.cun_chu_tiao_jian,
  436. shi_fou_guo_shen_: '启用',
  437. yang_pin_bian_hao: sampleInfo.yang_pin_bian_hao,
  438. yang_pin_ming_che: sampleInfo.yang_pin_ming_che,
  439. ru_ku_shi_jian_: sampleInfo.ru_ku_shi_jian_,
  440. shi_fou_liu_yang_: sampleInfo.shi_fou_liu_yang_,
  441. biao_zhi_uuid_: sampleInfo.biao_zhi_uuid_
  442. }
  443. return temp
  444. },
  445. handleLocationInfo(currentLocation, isLiuYang, localInfo, locationIds, item, UUID, currentTime) {
  446. !locationIds.has(currentLocation) ? locationIds.add(currentLocation) : localInfo.find(i => i.id_ === currentLocation).wei_zhi_zhuang_ta = '占用'
  447. console.log(localInfo.find(i => i.id_ === currentLocation), currentLocation)
  448. if (localInfo.find(i => i.id_ === currentLocation).wei_zhi_zhuang_ta === '空余') {
  449. let obj = {
  450. where: {
  451. id_: currentLocation
  452. },
  453. param: {
  454. wei_zhi_zhuang_ta: "占用",
  455. ru_ku_shi_jian_: currentTime,
  456. yang_pin_bian_hao: item.yang_pin_bian_hao,
  457. yang_pin_ming_che: item.yang_pin_ming_che,
  458. shi_fou_liu_yang_: isLiuYang
  459. }
  460. }
  461. let result = {
  462. name: 'emptyLocation',
  463. value: obj
  464. }
  465. return result
  466. } else { // 新增一条位置信息(修改它的样品编号,样品名称,入库时间,标识UUID)
  467. let sampleInfo = {
  468. yang_pin_bian_hao: item.yang_pin_bian_hao,
  469. yang_pin_ming_che: item.yang_pin_ming_che,
  470. ru_ku_shi_jian_: currentTime,
  471. biao_zhi_uuid_: UUID,
  472. shi_fou_liu_yang_: isLiuYang
  473. }
  474. let newLocation = this.generateNewLocation(localInfo.find(i => i.id_ === currentLocation), sampleInfo)
  475. let result = {
  476. name: 'fullLocation',
  477. value: newLocation
  478. }
  479. return result
  480. }
  481. },
  482. /* 关闭*/
  483. remRedar() {
  484. this.visible = false // 列表隐藏
  485. this.listData = [] // 清空列表数据
  486. this.redar = false // 扫码图标隐藏
  487. this.$emit('scanOff', false)
  488. },
  489. }
  490. }