manualConfirmationJS.js 31 KB

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