manualConfirmationJS.js 31 KB

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