sampleConfirmationJS.js 33 KB

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