manualConfirmationJS.js 34 KB

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