sampleConfirmationJS.js 31 KB

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