manualConfirmationJS.js 36 KB

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