manualConfirmationJS.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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. this.listData = []
  25. for (let i in temp) {
  26. temp[i].jie_yang_shu_lian = temp[i].yang_pin_zong_shu
  27. temp[i].jie_yang_zhuang_t = '已确认'
  28. temp[i].biao_zhi_uuid_ = this.uuid()
  29. temp[i].shi_fou_liu_yang_ = '是'
  30. temp[i].yan_shou_jie_guo_ = '完好'
  31. temp[i].liu_yang_shu_lian = ' ml/支×1支'
  32. temp[i].liu_yang_ri_qi_ = this.dateFormat()
  33. temp[i].liu_yang_qi_xian = dayjs(temp[i].song_jian_shi_jia).add(3,'month').format("YYYY-MM-DD")
  34. temp[i].xiao_hui_ri_qi_ = dayjs(temp[i].liu_yang_qi_xian).endOf('month').format("YYYY-MM-DD")
  35. this.listData.push(temp[i])
  36. }
  37. }else{
  38. this.handleEmptyData();
  39. }
  40. })
  41. },
  42. loadDataBySQL(page) {
  43. // 扫码扫到新数据,查询 并分页 回填展示
  44. let countSQL = `select count(*) as count from t_lhypb where jie_yang_zhuang_t = '待接收' and shi_fou_guo_shen_ = '1'`
  45. let str = (page-1)*10
  46. // let fysql = `select * from t_lhypb where jie_yang_zhuang_t = '待接收' and shi_fou_guo_shen_ = '1' limit ${str},10`
  47. 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'`
  48. Promise.all([repostCurd('sql', countSQL), repostCurd('sql', fysql)]).then(([res1, res]) => {
  49. this.listData = []
  50. this.pageCount = res1.variables.data[0].count
  51. if (res.variables.data && res.variables.data.length > 0) {
  52. for (let i in res.variables.data) {
  53. res.variables.data[i].jie_yang_shu_lian = res.variables.data[i].yang_pin_zong_shu
  54. res.variables.data[i].jie_yang_zhuang_t = '已确认'
  55. res.variables.data[i].biao_zhi_uuid_ = this.uuid()
  56. res.variables.data[i].shi_fou_liu_yang_ = '是'
  57. res.variables.data[i].yan_shou_jie_guo_ = '完好'
  58. res.variables.data[i].liu_yang_shu_lian = ' ml/支×1支'
  59. res.variables.data[i].liu_yang_ri_qi_ = this.dateFormat()
  60. res.variables.data[i].liu_yang_qi_xian = dayjs(res.variables.data[i].song_jian_shi_jia).add(3,'month').format("YYYY-MM-DD")
  61. res.variables.data[i].xiao_hui_ri_qi_ = dayjs(res.variables.data[i].liu_yang_qi_xian).endOf('month').format("YYYY-MM-DD")
  62. this.listData.push(res.variables.data[i])
  63. }
  64. }else{
  65. this.handleEmptyList();
  66. }
  67. })
  68. },
  69. handleEmptyData(){
  70. this.$confirm('您所选择的样品还未到实验室现场,无法接样!').then(_ => {
  71. this.closeDialog();
  72. }).catch(_ => {});
  73. },
  74. handleEmptyList(){
  75. this.$confirm('目前暂无样品需要接样!').then(_ => {
  76. this.closeDialog();
  77. }).catch(_ => {});
  78. },
  79. /* 列表失去焦点*/
  80. handleChange() {
  81. this.$refs.redarInput.focus(); //聚焦input
  82. },
  83. /* 关闭弹出列表框*/
  84. closeDialog() {
  85. this.remRedar()
  86. //回传关闭事件。隐藏当前组件。
  87. },
  88. handleClose() {
  89. this.handleChange()
  90. this.$confirm('确认关闭样品列表页面?').then(_ => {
  91. this.closeDialog();
  92. }).catch(_ => {});
  93. },
  94. submitData(type) {
  95. // this指针
  96. let this_ = this;
  97. let changeWeiZhi; // 此处俩字段作用在下面 选择货位时出现重复位置 而重新更新样品登记表 收样位置|留样位置
  98. let changesyWeiZhi;
  99. // 回传关闭事件。隐藏当前组件。
  100. let judge = true;
  101. if (this_.listData.length == 0) {
  102. this.$emit('callback', true)
  103. this.visable = false
  104. this.$message({
  105. message: '暂无样品待接收确认!',
  106. type: 'error'
  107. })
  108. this.closeDialog();
  109. } else {
  110. this.$confirm('请再次确认 [样品接收信息]').then(_ => {
  111. // 获取样品列表
  112. let ypInfoList = this_.listData
  113. // console.log(ypInfoList, "样品信息")
  114. let dWhere = []
  115. let ypbh = []
  116. let cfwzIdList = [] // 放置 存放位置的ID
  117. let ypbhList = [] // 样品编号列表
  118. // 罗湖样品编号列表
  119. let lhypbhList = []
  120. let lhypmcList = []
  121. // 罗湖委托单列表
  122. let lhwtsqbList = []
  123. // 罗湖样品表列表
  124. let lhypbList = []
  125. // 罗湖样品表外键
  126. let lhypbWJ = []
  127. // 罗湖委托表主键
  128. let lhwtbID = []
  129. let lhwtbOnlyId = []
  130. // 罗湖委托表展示表ID
  131. let lhwtzsbID = []
  132. // 罗湖样品id列表
  133. let lhypIdList = []
  134. // 罗湖样品id格式列表
  135. let lhypIdNewList = []
  136. let uuidList = [] // 列表的UUID
  137. for (let yp in ypInfoList) { //样品数据
  138. let cfwzObj = []
  139. let cfwz = ''
  140. /*
  141. 校验:
  142. 1、样品数量 <= 确认数量
  143. 2、是否留样 => 填收样位置|留样位置
  144. 3、验收结果必填
  145. 4、如果留样 => 必填项:留样日期、留样数量、留样期限至、销毁日期
  146. */
  147. if (ypInfoList[yp].jie_yang_shu_lian > ypInfoList[yp].yang_pin_zong_shu) {
  148. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 接收确认数量不得大于收样数量。')
  149. return;
  150. }
  151. if (ypInfoList[yp].jie_yang_zhuang_t == '未确认') {
  152. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 接收确认状态必须为已确认。')
  153. return;
  154. }
  155. if (ypInfoList[yp].yan_shou_jie_guo_ == null || ypInfoList[yp].yan_shou_jie_guo_ == '') {
  156. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 验收结果不能为空!')
  157. return;
  158. }
  159. if (ypInfoList[yp].shi_fou_liu_yang_ == null || ypInfoList[yp].shi_fou_liu_yang_ == '') {
  160. this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 是否留样不能为空!')
  161. return;
  162. }
  163. // if (ypInfoList[yp].bao_gao_bian_zhi_ == undefined || ypInfoList[yp].bao_gao_bian_zhi_ == '') {
  164. // this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 报告编制员不能为空!')
  165. // return;
  166. // }
  167. // if (ypInfoList[yp].bao_gao_shen_he_y == undefined || ypInfoList[yp].bao_gao_shen_he_y == '') {
  168. // this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 报告审核员不能为空!')
  169. // return;
  170. // }
  171. cfwzObj.push(ypInfoList[yp].shou_yang_wei_zhi) //取位置信息
  172. if (ypInfoList[yp].shi_fou_liu_yang_ == "是") {
  173. if (ypInfoList[yp].liu_yang_wei_zhi_ == null || ypInfoList[yp].liu_yang_wei_zhi_ == '') {
  174. this_.$message.error("你要留样的话,存放位置不能为空哦!")
  175. return;
  176. }
  177. // if (ypInfoList[yp].shou_yang_wei_zhi != undefined && ypInfoList[yp].shou_yang_wei_zhi != '') {
  178. // this_.$message.error("你要留样的话,就不要选收样存放位置!")
  179. // return;
  180. // }
  181. if (ypInfoList[yp].liu_yang_ri_qi_ == null || ypInfoList[yp].liu_yang_ri_qi_ == '') {
  182. this_.$message.error("留样时必须填写留样日期!")
  183. return;
  184. }
  185. if (ypInfoList[yp].liu_yang_shu_lian == null || ypInfoList[yp].liu_yang_shu_lian == '') {
  186. this_.$message.error("留样时必须填写留样数量!")
  187. return;
  188. }
  189. // if (ypInfoList[yp].liu_yang_shu_lian > ypInfoList[yp].yang_pin_zong_shu) {
  190. // this_.$message.error('操作失败,[' + ypInfoList[yp].yang_pin_ming_che + '] 留样数量不得大于收样数量。')
  191. // return;
  192. // }
  193. if (ypInfoList[yp].liu_yang_qi_xian == null || ypInfoList[yp].liu_yang_qi_xian == '') {
  194. this_.$message.error("留样时必须填写留样期限!")
  195. return;
  196. }
  197. if (ypInfoList[yp].xiao_hui_ri_qi_ == null || ypInfoList[yp].xiao_hui_ri_qi_ == '') {
  198. this_.$message.error("留样时必须填写销毁日期!")
  199. return;
  200. }
  201. // cfwz = ypInfoList[yp].liu_yang_wei_zhi_
  202. cfwzObj.push(ypInfoList[yp].liu_yang_wei_zhi_)
  203. }
  204. // else {
  205. // if (ypInfoList[yp].shou_yang_wei_zhi == null || ypInfoList[yp].shou_yang_wei_zhi == '') {
  206. // this_.$message.error("你正常收样的话,样品存放位置不能为空哦!")
  207. // return;
  208. // }
  209. // if (ypInfoList[yp].liu_yang_wei_zhi_ != undefined && ypInfoList[yp].liu_yang_wei_zhi_ != '') {
  210. // this_.$message.error("你正常收样的话,就不要选择留样存放位置!")
  211. // return;
  212. // }
  213. // cfwz = ypInfoList[yp].shou_yang_wei_zhi //取位置信息
  214. // }
  215. // uuidList.push(ypInfoList[yp].biao_zhi_uuid_)
  216. // ypIdList.push('{"id_":"' + ypInfoList[yp].id_ + '"}')
  217. // ypWeiZhi.push(ypInfoList[yp].shou_yang_wei_zhi) // 收样存放位置
  218. // ypLiuYangWeiZhi.push(ypInfoList[yp].liu_yang_wei_zhi_) // 留样存放位置
  219. // saoMaNumList.push(ypInfoList[yp].jie_yang_shu_lian) // 扫码数量
  220. // jieYangQueRenZTList.push(ypInfoList[yp].jie_yang_zhuang_t) // 接收确认状态
  221. ypbhList.push('{"yang_pin_bian_hao":"' + ypInfoList[yp].yang_pin_bian_hao + '"}') // 样品编号列表
  222. // 罗湖
  223. // lhypbhList.push('{"yang_pin_bian_hao":"' + ypInfoList[yp].yang_pin_bian_hao + '"}')
  224. // lhypbWJ.push('{"id_":"' + ypInfoList[yp].parent_id_ + '"}')
  225. dWhere.push('{"id_":"' + cfwz + '"}')
  226. cfwzIdList.push(cfwzObj)
  227. lhypbhList.push( ypInfoList[yp].yang_pin_bian_hao )
  228. lhypbWJ.push( ypInfoList[yp].parent_id_ )
  229. lhypIdList.push( ypInfoList[yp].id_ )
  230. lhypIdNewList.push('{"id_":"' + ypInfoList[yp].id_ + '"}')
  231. uuidList.push(ypInfoList[yp].biao_zhi_uuid_)
  232. ypbh.push(ypInfoList[yp].yang_pin_bian_hao)
  233. lhypmcList.push(ypInfoList[yp].yang_pin_ming_che)
  234. }
  235. /*
  236. 封装好样品登记表对象,add 样品登记表
  237. */
  238. let value = ''
  239. let lhypIdStr = ''
  240. for(let i =0;i<lhypbWJ.length; i++){
  241. value += lhypbWJ[i] + ','
  242. }
  243. value = value.substring(0,value.length-1)
  244. value = value.replace(/,/g,"','")
  245. for(let i = 0; i<lhypIdList.length;i++){
  246. lhypIdStr += lhypIdList[i] + ','
  247. }
  248. lhypIdStr = lhypIdStr.substring(0,lhypIdStr.length-1)
  249. lhypIdStr = lhypIdStr.replace(/,/g,"','")
  250. // console.log('lhypIdStr :',lhypIdStr)
  251. let wtdAndYpb = []
  252. // a.bao_gao_bian_zhi_,a.bao_gao_fu_he_yua,
  253. 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}')`
  254. // console.log(allSQL)
  255. repostCurd('sql', allSQL).then(res1 => {
  256. /* 封装样品登记表对象 */
  257. let ypdjb = []
  258. let res = res1.variables.data
  259. wtdAndYpb = res
  260. for(let i = 0; i<res.length; i++){
  261. lhwtbID.push('{"id_":"' + res[i].wtID + '"}')
  262. lhwtbOnlyId.push(res[i].wtID)
  263. lhwtzsbID.push('{"shen_qing_id_":"' + res[i].zhan_shi_biao_id_ + '"}')
  264. let count = 0;
  265. if(res[i].yang_pin_lei_xing != '' && res[i].yang_pin_lei_xing != undefined){
  266. count = 1;
  267. if(res[i].yang_pin_lei_er_ != '' && res[i].yang_pin_lei_er_ != undefined){
  268. count = 2;
  269. if(res[i].yang_pin_lei_san_ != '' && res[i].yang_pin_lei_san_ != undefined){
  270. count = 3;
  271. if(res[i].yang_pin_lei_si_ != '' && res[i].yang_pin_lei_si_ != undefined){
  272. count = 4;
  273. }
  274. }
  275. }
  276. }
  277. for(let x = 0; x<count;x++){
  278. let obj = {}
  279. obj["wei_tuo_dan_hao_"] = res[i].wei_tuo_bian_hao_
  280. obj["wei_tuo_dan_wei_"] = res[i].wtdh
  281. obj["lian_xi_ren_"] = res[i].wei_tuo_fang_lian
  282. obj["lian_xi_dian_hua_"] = res[i].wei_tuo_lian
  283. obj["yang_ben_ming_che"] = res[i].yang_pin_ming_che
  284. obj["yang_ben_bian_hao"] = res[i].yang_pin_bian_hao
  285. obj["pi_hao_bian_hao_"] = res[i].song_jian_pi_hao_
  286. obj["xing_ming_"] = res[i].xing_ming_
  287. obj["xing_bie_"] = res[i].xing_bie_
  288. obj["nian_ling_"] = res[i].nian_ling_
  289. obj["yang_ben_zhuang_t"] = res[i].yang_pin_zhuang_t
  290. obj["shou_yang_ri_qi_"] = this_.dateFormat()
  291. obj["bei_zhu_"] = ypInfoList[i].bei_zhu_
  292. obj["yang_ben_lei_xing"] = x==0? res[i].yang_pin_lei_xing : x==1? res[i].yang_pin_lei_er_ : x==2? res[i].yang_pin_lei_san_ : x==3? res[i].yang_pin_lei_si_ :''
  293. obj["yun_shu_tiao_jian"] = x==0? res[i].yang_ben_yun_shu_ : x==1? res[i].yang_pin_yun_shu_ : x==2? res[i].yang_pin_yun_san : x==3? res[i].yang_pin_yun_si_ :''
  294. obj["yang_pin_shu_lian"] = x==0? res[i].shu_liang_ : x==1? res[i].shu_liang_er_ : x==2? res[i].shu_liang_san_ : x==3? res[i].shu_liang_si_ :''
  295. obj["yang_ben_gui_ge_s"] = x==0? res[i].yang_pin_gui_ge_ : x==1? res[i].yang_pin_gui_ge_e : x==2? res[i].yang_pin_gui_ge_s : x==3? res[i].yang_pin_gui_si_ :''
  296. obj["yan_shou_jie_guo_"] = ypInfoList[i].yan_shou_jie_guo_
  297. obj["cun_fang_wei_zhi_"] = ypInfoList[i].shou_yang_wei_zhi
  298. obj["liu_zhuan_zhuang_"] = '待检'
  299. obj["shi_fou_liu_yang_"] = ypInfoList[i].shi_fou_liu_yang_
  300. obj["liu_yang_ri_qi_"] = ypInfoList[i].liu_yang_ri_qi_
  301. obj["liu_yang_cun_fang"] = ypInfoList[i].liu_yang_wei_zhi_
  302. obj["liu_yang_shu_lian"] = ypInfoList[i].liu_yang_shu_lian
  303. obj["liu_yang_qi_xian"] = ypInfoList[i].liu_yang_qi_xian
  304. obj["xiao_hui_ri_qi_"] = ypInfoList[i].xiao_hui_ri_qi_
  305. obj["fan_yang_ri_qi_"] = ypInfoList[i].fan_yang_ri_qi_
  306. obj["fan_yang_jyr"] = ypInfoList[i].fan_yang_jyr
  307. obj["biao_zhi_uuid_"] = ypInfoList[i].biao_zhi_uuid_
  308. obj["song_yang_yao_qiu"] = ypInfoList[i].song_yang_yao_qiu
  309. // obj["fen_zhuang_liu_ya"] = ypInfoList[i].fen_zhuang_liu_ya
  310. changeWeiZhi = ypInfoList[i].shou_yang_wei_zhi ==''?'':ypInfoList[i].shou_yang_wei_zhi
  311. changesyWeiZhi = ypInfoList[i].liu_yang_wei_zhi_ ==''?'':ypInfoList[i].liu_yang_wei_zhi_
  312. ypdjb.push(obj)
  313. }
  314. }
  315. let fbbIdStr = ''
  316. for(let i =0;i<lhwtbOnlyId.length; i++){
  317. fbbIdStr += lhwtbOnlyId[i] + ','
  318. }
  319. fbbIdStr = fbbIdStr.substring(0,fbbIdStr.length-1)
  320. // fbbIdStr = fbbIdStr.replace(/,/g,"','")
  321. // console.log('fbbIdStr :',fbbIdStr)
  322. // console.log('进入样品登记表...',ypdjb)
  323. repostCurd('add', '{"tableName":"t_lhypdjb","paramWhere":' + JSON.stringify(ypdjb) + '}')
  324. repostCurd('updates', '{"tableName":"t_lhypb","paramWhere":[' + lhypIdNewList + '],"paramCond":{"jie_yang_zhuang_t":"已接收"}}')
  325. /*
  326. 更新委托单 如果本来没值,就更新 报告编制人和 报告审核员 否则更新
  327. 委托单数组 和 样品数组 数量相同,遍历两者 判断委托单是否有编制人,审核员?
  328. 如果没有,则记录下委托单ID,以及同索引下的样品表的编制人和审核员
  329. */
  330. // let finalWtdIdList = []
  331. /**
  332. * 1.11胡老师说不要
  333. for(var index = 0; index < ypInfoList.length; index++){
  334. if(res[index].bao_gao_bian_zhi_ == '' || res[index].bao_gao_fu_he_yua == ''){
  335. repostCurd('update','{"tableName":"t_lhwtsqb","paramWhere":' + '{"id_":"' + res[index].wtID + '"}' + ',"paramCond":' + '{"bao_gao_bian_zhi_":"'+ypInfoList[index].bao_gao_bian_zhi_+'","bao_gao_fu_he_yua":"' + ypInfoList[index].bao_gao_shen_he_y + '"}}')
  336. }
  337. }
  338. */
  339. /*
  340. let wtdSQL = "select id_,bao_gao_bian_zhi_,bao_gao_fu_he_yua from t_lhwtsqb where id_ in('" + value + "')"
  341. repostCurd('sql', wtdSQL).then(response => {
  342. let result = response.variables.data
  343. console.log(result)
  344. for(var i in result){
  345. if(result[i].bao_gao_bian_zhi_ == '' || result[i].bao_gao_bian_zhi_ == undefined){
  346. finalWtdIdList.push(result[i])
  347. }
  348. }
  349. console.log('finalWtdIdList',finalWtdIdList)
  350. })
  351. */
  352. /*
  353. 3、任务分配 【2022/11/23 取消 直接 批量开检测子流程】【2022/11/30 胡老师又要】
  354. 3-1、根据 wtdAndYpb 的 wtID 更改委托表的 委托状态 wei_tuo_zhuang_ta 变成 已完成
  355. 3-2、根据每个样品一个任务分配流程 遍历样品表开任务分配流程
  356. 3-3、委托表找zhan_shi_biao_id_ 修改 t_lhwtzsb "zhuang_tai_"为"待任务分配"
  357. */
  358. // console.log('委托单及样品信息',wtdAndYpb)
  359. // console.log('委托单id列表 ',lhwtbID)
  360. // console.log('展示表id列表 ',lhwtzsbID)
  361. repostCurd('updates', '{"tableName":"t_lhwtsqb","paramWhere":[' + lhwtbID + '],"paramCond":{"wei_tuo_zhuang_ta":"已完成"}}')
  362. let rws = []
  363. if(wtdAndYpb.length>0){
  364. for(var i in wtdAndYpb){
  365. // let strs = wtdAndYpb[i].jian_ce_xiang_mu_.split(',')
  366. // for(var l in strs){
  367. let rw = {}
  368. // rw["ren_wu_ming_cheng"] = strs[l] //检测项目
  369. rw["yang_pin_ming_che"] = wtdAndYpb[i].yang_pin_ming_che//样品名称
  370. rw["yang_pin_bian_hao"] = wtdAndYpb[i].yang_pin_bian_hao//样品编号
  371. rw["wei_tuo_lei_xing_"] = wtdAndYpb[i].wei_tuo_lei_xing_ //委托类型
  372. let yplxz = ''
  373. if(wtdAndYpb[i].yang_pin_lei_xing != null && wtdAndYpb[i].yang_pin_lei_xing!=''){ //样品类型1
  374. yplxz = wtdAndYpb[i].yang_pin_lei_xing //样品类型
  375. }
  376. if(wtdAndYpb[i].yang_pin_lei_er_ != null && wtdAndYpb[i].yang_pin_lei_er_!=''){ //样品类型2
  377. if(yplxz==null || yplxz == ''){
  378. yplxz = wtdAndYpb[i].yang_pin_lei_er_ //样品类型
  379. }else{
  380. yplxz =yplxz+','+ wtdAndYpb[i].yang_pin_lei_er_ //样品类型
  381. }
  382. }
  383. if(wtdAndYpb[i].yang_pin_lei_san_ != null && wtdAndYpb[i].yang_pin_lei_san_!=''){ //样品类型3
  384. if(yplxz==null || yplxz == ''){
  385. yplxz = wtdAndYpb[i].yang_pin_lei_san_ //样品类型
  386. }else{
  387. yplxz =yplxz+','+ wtdAndYpb[i].yang_pin_lei_san_ //样品类型
  388. }
  389. }
  390. if(wtdAndYpb[i].yang_pin_lei_si_ != null && wtdAndYpb[i].yang_pin_lei_si_!=''){ //样品类型4
  391. if(yplxz==null || yplxz == ''){
  392. yplxz = wtdAndYpb[i].yang_pin_lei_si_ //样品类型
  393. }else{
  394. yplxz = yplxz+','+ wtdAndYpb[i].yang_pin_lei_si_ //样品类型
  395. }
  396. }
  397. rw["yang_pin_lei_xing"] = yplxz // 样品类型
  398. rw["wei_tuo_id_"] = wtdAndYpb[i].wtID // 委托id
  399. rw["he_tong_id_"] = wtdAndYpb[i].he_tong_id_ // 合同id
  400. rw["zhuang_tai_"] = '待任务分配' // 状态
  401. rw["wan_cheng_shi_jia"] = wtdAndYpb[i].song_jian_shi_jia // 送检日期
  402. // rw["bao_gao_bian_zhi_"] = ypInfoList[i].bao_gao_bian_zhi_ // 报告编制人
  403. // rw["bao_gao_shen_he_y"] = ypInfoList[i].bao_gao_shen_he_y // 报告审核人
  404. rw["bao_gao_lei_xing_"] = wtdAndYpb[i].bao_gao_lei_xing_ // 报告类型
  405. rw["xin_xiang_mu_ming"] = wtdAndYpb[i].xiang_mu_ming_che // 项目名称
  406. rw["zhan_shi_biao_id_"] = wtdAndYpb[i].zhan_shi_biao_id_ // 展示表id
  407. rw["fen_zhuang_liu_ya"] = ypInfoList[i].liu_yang_shu_lian // 留样数量
  408. rw["shi_fou_jia_ji_"] = wtdAndYpb[i].chu_ju_bao_gao_ya // 是否加急【2023/2/23王嘎嘎提出】
  409. rw["yang_pin_shu_lian"] = ypInfoList[i].jie_yang_shu_lian // 样品确认总数【2023/3/7王嘎嘎提出】
  410. rws.push(rw)
  411. // }
  412. }
  413. // console.log("任务分配",rws)
  414. repostCurd('add', '{"tableName":"t_lhrwfpb","paramWhere":'+JSON.stringify(rws)+',"defKey":"Process_04o0csc","formKey":"lhrwfp"}')
  415. }
  416. // 更新委托单 检测开始时间 问吴懿是否需要 不需要
  417. // repostCurd('updates', '{"tableName":"t_lhwtsqb","paramWhere":[' + lhwtbID + '],"paramCond":{"jian_ce_kai_shi_s":"' + this_.dateFormat() + '"}}')
  418. //更新展示表
  419. if(lhwtzsbID.length > 0){
  420. repostCurd('updates', '{"tableName":"t_lhwtzsb","paramWhere":['+lhwtzsbID+'],"paramCond":{"zhuang_tai_":"任务分配进行中"}}')
  421. }
  422. /*
  423. 3、【任务分配2022/11/23 取消 直接 批量开检测子流程】【2022/11/30 取消】
  424. 3-1、根据 wtdAndYpb 的 wtID 更改委托表的 委托状态 wei_tuo_zhuang_ta 变成 已完成
  425. 3-2、根据每个样品对应的检测项目,开启一个或多个任务 / 遍历样品表开检测子流程,一个样品可能对应多个检测
  426. 3-3、委托表找zhan_shi_biao_id_ 修改 t_lhwtzsb "zhuang_tai_"为"待环境监控"
  427. repostCurd('updates', '{"tableName":"t_lhwtsqb","paramWhere":[' + lhwtbID + '],"paramCond":{"wei_tuo_zhuang_ta":"已完成"}}')
  428. */
  429. // console.log('dwhere:',dWhere)
  430. // console.log('cfwzIdList:',cfwzIdList)
  431. /* 2、更新货架位置信息(位置状态、样品编号、入库时间)如果是重复位置,则新增一条位置记录,并增加对应UUID
  432. 判断是否是留样位置,如果是留样位置 位置表shi_fou_liu_yang_字段值为`是` 否则 值为`否`
  433. */
  434. for (let num in dWhere) {
  435. let firstIfEmpty = true
  436. let secondIfEmpty = true
  437. for(let index = 0; index<cfwzIdList[num].length; index++){
  438. let sql = "select * from t_ypcfwz where id_ = '" + cfwzIdList[num][index] + "'"
  439. let isLiuYang = index == 1 ? "是" : "否"
  440. // console.log(sql)
  441. repostCurd('sql', sql).then(response => {
  442. let resArr = response.variables.data
  443. // console.log(resArr)
  444. if (resArr.length == 1) {
  445. if (resArr[0].wei_zhi_zhuang_ta == "空余") {
  446. if(index == 0){
  447. firstIfEmpty = false
  448. }else{
  449. secondIfEmpty = false
  450. }
  451. let content = {
  452. id_ : cfwzIdList[num][index]
  453. }
  454. let params = {
  455. wei_zhi_zhuang_ta : "占用",
  456. ru_ku_shi_jian_ : this_.dateFormat(),
  457. yang_pin_bian_hao : ypbh[num],
  458. yang_pin_ming_che : lhypmcList[num],
  459. shi_fou_liu_yang_ : isLiuYang
  460. }
  461. let o = {
  462. tableName:'t_ypcfwz',
  463. paramWhere:content,
  464. paramCond : params
  465. }
  466. repostCurd('update',JSON.stringify(o)).then(res=>{
  467. console.log("空余位置修改")
  468. })
  469. } else if (resArr[0].wei_zhi_zhuang_ta == "占用") {
  470. // 新增一条新的位置记录,使用旧的位置记录 修改它的样品编号,入库时间,标识UUID
  471. let cfNewList = []
  472. let cfNew = {}
  473. cfNew["fang_jian_lei_xin"] = resArr[0].fang_jian_lei_xin
  474. cfNew["wei_zhi_"] = resArr[0].wei_zhi_
  475. cfNew["qu_yu_"] = resArr[0].qu_yu_
  476. cfNew["huo_jia_lei_xing_"] = resArr[0].huo_jia_lei_xing_
  477. cfNew["huo_jia_hao_"] = resArr[0].huo_jia_hao_
  478. cfNew["ceng_hao_"] = resArr[0].ceng_hao_
  479. cfNew["shui_ping_fen_qu_"] = resArr[0].shui_ping_fen_qu_
  480. cfNew["wei_zhi_bian_hao_"] = resArr[0].wei_zhi_bian_hao_
  481. cfNew["wei_zhi_zhuang_ta"] = resArr[0].wei_zhi_zhuang_ta
  482. cfNew["cun_chu_tiao_jian"] = resArr[0].cun_chu_tiao_jian
  483. cfNew["yang_pin_bian_hao"] = ypbh[num]
  484. cfNew["shi_fou_guo_shen_"] = '启用'
  485. // cfNew["yang_pin_bian_hao"] = lhypIdList[num]
  486. cfNew["yang_pin_ming_che"] = lhypmcList[num]
  487. cfNew["ru_ku_shi_jian_"] = this_.dateFormat()
  488. cfNew["shi_fou_liu_yang_"] = isLiuYang
  489. cfNew["biao_zhi_uuid_"] = uuidList[num]
  490. cfNewList.push(cfNew)
  491. let uuid = cfNew["biao_zhi_uuid_"];
  492. // console.log('货位:',cfNewList)
  493. repostCurd('add', '{"tableName":"t_ypcfwz","paramWhere":' + JSON.stringify(cfNewList) + '}').then(res => {
  494. let selectsql = "select id_ from t_ypcfwz where biao_zhi_uuid_='" + uuid + "'";
  495. repostCurd('sql', selectsql).then(res => {
  496. // let dataid = res.variables.data[0].id_;
  497. let data = res.variables.data;
  498. // console.log('data:',data)
  499. let suchAs = '{"biao_zhi_uuid_":"' + uuid + '"}'
  500. // console.log(data.length,changeWeiZhi,changesyWeiZhi,firstIfEmpty,secondIfEmpty)
  501. if(data.length == 1 && changeWeiZhi && firstIfEmpty){
  502. repostCurd('update', '{"tableName":"t_lhypdjb","paramWhere":'+suchAs+',"paramCond":{"cun_fang_wei_zhi_":"'+data[0].id_+'"}}').then(res=>{
  503. console.log('One 存放位置',res)
  504. })
  505. }else if(data.length == 1 && changesyWeiZhi && secondIfEmpty){
  506. repostCurd('update', '{"tableName":"t_lhypdjb","paramWhere":'+suchAs+',"paramCond":{"liu_yang_cun_fang":"'+data[0].id_+'"}}').then(res=>{
  507. console.log('One 留样位置',res)
  508. })
  509. }else if(data.length == 2 && changeWeiZhi && changesyWeiZhi){
  510. let whereL = []
  511. whereL.push(suchAs)
  512. repostCurd('updates', '{"tableName":"t_lhypdjb","paramWhere":['+whereL+'],"paramCond":{"cun_fang_wei_zhi_":"'+data[0].id_+'","liu_yang_cun_fang":"'+data[1].id_+'"}}').then(res=>{
  513. console.log('Two 收样留样位置',res)
  514. })
  515. }
  516. })
  517. })
  518. }
  519. }
  520. })
  521. }
  522. }
  523. /*
  524. let ffbSql = "select * from t_lhfbb where FIND_IN_SET( parent_id_,'"+ fbbIdStr +"')"
  525. repostCurd('sql',ffbSql).then(response => {
  526. let ffbList = response.variables.data
  527. if(wtdAndYpb.length>0){
  528. let jcxmArr = []
  529. wtdAndYpb.forEach(item=>{
  530. item.jian_ce_xiang_mu_.split(',').reverse().forEach(temp=>{
  531. jcxmArr.push(temp)
  532. })
  533. })
  534. let allProject = []
  535. let finalJCTask = []
  536. let processDefKeyParam = []
  537. let processFormKeyParam = []
  538. let sql111 = `select id_, defkey_, formkey_ from t_mjjcnlfw where defkey_ != '' and find_in_set(id_, '${jcxmArr.join(',')}')`
  539. repostCurd('sql', sql111).then(res => {
  540. allProject = res.variables.data
  541. wtdAndYpb.forEach(item => {
  542. let yblxArr = []
  543. let yblxStr = ''
  544. yblxArr.push(item.yang_pin_lei_xing, item.yang_pin_lei_er_, item.yang_pin_lei_san_, item.yang_pin_lei_si_)
  545. yblxStr = yblxArr.filter(s => s).join(',')
  546. let t = item.jian_ce_xiang_mu_.split(',')
  547. let ypList = ypInfoList.find(k => k.id_ === item.id_)
  548. t.forEach(i => {
  549. let fbbItem = ffbList.find(j => j.jian_ce_xiang_mu_ === i)
  550. let jcxmItem = allProject.find(k => k.id_ === i)
  551. let obj = {
  552. jian_ce_yuan_: fbbItem.jian_ce_yuan_,
  553. fu_he_yuan_ : fbbItem.fu_he_yuan_,
  554. yang_pin_ming_che: item.yang_pin_ming_che,
  555. yang_pin_bian_hao: item.yang_pin_bian_hao,
  556. jian_ce_xiang_mu_:jcxmItem.id_,
  557. wei_tuo_id_:item.wtID,
  558. he_tong_id_:item.he_tong_id_,
  559. bao_gao_bian_zhi_:ypList.bao_gao_bian_zhi_,
  560. bao_gao_fu_he_yua:ypList.bao_gao_shen_he_y,
  561. wei_tuo_lei_xing_:item.wei_tuo_lei_xing_,
  562. yang_pin_lei_xing: yblxStr,
  563. xin_xiang_mu_ming:item.xiang_mu_ming_che,
  564. wan_cheng_shi_jia:item.song_jian_shi_jia,
  565. zhuang_tai_:'待环境监控',
  566. zhan_shi_biao_id_:item.zhan_shi_biao_id_
  567. }
  568. finalJCTask.push(obj)
  569. processDefKeyParam.push(jcxmItem.defkey_)
  570. processFormKeyParam.push(jcxmItem.formkey_)
  571. })
  572. })
  573. finalJCTask.forEach((item,index )=>{
  574. let obj = {
  575. tableName:"t_lhjczb",
  576. paramWhere:[item],
  577. defKey:processDefKeyParam[index],
  578. formKey:processFormKeyParam[index]
  579. }
  580. repostCurd('add', JSON.stringify(obj))
  581. })
  582. })
  583. }
  584. })
  585. //更新展示表
  586. if(lhwtzsbID.length > 0){
  587. repostCurd('updates', '{"tableName":"t_lhwtzsb","paramWhere":['+lhwtzsbID+'],"paramCond":{"zhuang_tai_":"检测进行中"}}')
  588. }
  589. */
  590. })
  591. this.$emit('callback', true)
  592. this.visable = false
  593. this.$message({
  594. message: '样品接收确认操作成功!',
  595. type: 'success'
  596. })
  597. this.closeDialog();
  598. }).catch(_ => {});
  599. }
  600. },
  601. /* 去除指定行数据 使用过滤器filter过滤指定行号数据 */
  602. deleteData(val) {
  603. this.listData = this.listData.filter((data) => {
  604. return data.id_ != val
  605. })
  606. },
  607. unique(arr) {
  608. return arr.filter((item, index) => {
  609. return arr.indexOf(item, 0) === index;
  610. });
  611. },
  612. uuid() {
  613. var s = [];
  614. var hexDigits = "0123456789abcdef";
  615. for (var i = 0; i < 36; i++) {
  616. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  617. }
  618. s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
  619. s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  620. s[8] = s[13] = s[18] = s[23] = "-";
  621. var uuid = s.join("");
  622. return uuid;
  623. },
  624. Update(name, where, cond) {
  625. let cont = {}
  626. cont['tableName'] = name
  627. cont['paramWhere'] = where
  628. cont['paramCond'] = cond
  629. return repostCurd('update', JSON.stringify(cont))
  630. },
  631. /* zzj add */
  632. dateFormat() { // 获取当前时间
  633. var date = new Date();
  634. var year = date.getFullYear();
  635. var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  636. var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  637. return year + "-" + month + "-" + day;
  638. },
  639. /* 关闭*/
  640. remRedar() {
  641. this.visible = false // 列表隐藏
  642. this.listData = [] // 清空列表数据
  643. this.redar = false // 扫码图标隐藏
  644. this.$emit('scanOff', false)
  645. },
  646. }
  647. }