manualConfirmationJS.js 41 KB

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