manualConfirmationJS.js 35 KB

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