sampleConfirmationJS.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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_mjypdjb","paramWhere":{"yang_pin_bian_hao":"S220909-1053"}}').then(response => {
  30. repostCurd('select','{"tableName": "t_mjypdjb","paramWhere":{"yang_pin_bian_hao":"' + id + '"}}').then(response => {
  31. if (response.variables.data && response.variables.data.length > 0) {
  32. // console.log(response.variables.data[0])
  33. response.variables.data[0].jie_yang_shu_lian = 1
  34. this.listData.push(response.variables.data[0])
  35. this.OriginalPosition.push(response.variables.data[0].shi_fou_liu_yang_ == "是" ? response.variables.data[0].liu_yang_wei_zhi_ : response.variables.data[0].shou_yang_wei_zhi)
  36. }
  37. })
  38. }
  39. },
  40. /* 列表失去焦点*/
  41. handleChange(){
  42. this.$refs.redarInput.focus(); //聚焦input
  43. },
  44. /* 关闭弹出列表框*/
  45. closeDialog() {
  46. this.remRedar()
  47. //回传关闭事件。隐藏当前组件。
  48. },
  49. handleClose(){
  50. this.handleChange()
  51. this.$confirm('确认关闭扫码列表页面?').then(_ => {
  52. this.closeDialog();
  53. }).catch(_ => {
  54. });
  55. },
  56. submitData(type) {
  57. // this指针
  58. let this_ = this;
  59. let changeWeizhi;
  60. let changesyWeizhi;
  61. // 回传关闭事件。隐藏当前组件。
  62. let judge = true;
  63. this.$confirm('请再次确认 [样品接收信息]').then(_ => {
  64. // 获取样品列表
  65. let ypInfoList = this_.listData
  66. // console.log(ypInfoList)
  67. let dWhere = []
  68. let ypbh = []
  69. let cfwzIdList = [] // 放置 存放位置的ID
  70. let uuidList = [] // 列表的UUID
  71. let ypIdList = [] // 样品id列表,格式转好的
  72. let ypWeiZhi = [] // 样品收样位置
  73. let ypLiuYangWeiZhi = [] // 样品留样位置
  74. let saoMaNumList = [] // 扫码确认数量列表
  75. let jieYangQueRenZTList = [] // 接样状态列表
  76. let ypbhList = [] // 样品编号列表
  77. let mjypbList = [] // 明鉴样品表
  78. let mjypbWJ = [] // 明鉴样品表外键
  79. for(let yp in ypInfoList){
  80. let cfwz = ''
  81. if(ypInfoList[yp].jie_yang_shu_lian > ypInfoList[yp].shou_yang_shu_lia){
  82. this_.$message.error('操作失败,['+ypInfoList[yp].yang_pin_ming_che+'] 接收确认数量不得大于收样数量。')
  83. return;
  84. }
  85. if(ypInfoList[yp].jie_yang_zhuang_t == '待确认'){
  86. this_.$message.error('操作失败,['+ypInfoList[yp].yang_pin_ming_che+'] 接收确认状态必须为已确认。')
  87. return;
  88. }
  89. if(ypInfoList[yp].shi_fou_liu_yang_ == "是"){
  90. if(ypInfoList[yp].liu_yang_wei_zhi_ == null || ypInfoList[yp].liu_yang_wei_zhi_ == ''){
  91. this_.$message.error("你要留样的话,存放位置不能为空哦!")
  92. return;
  93. }
  94. if(ypInfoList[yp].shou_yang_wei_zhi != undefined && ypInfoList[yp].shou_yang_wei_zhi != ''){
  95. this_.$message.error("你要留样的话,就不要选收样存放位置!")
  96. return;
  97. }
  98. let isLy = ypInfoList[yp].liu_yang_wei_zhi_
  99. if(isLy.substr(-2,isLy.length -1) == "占用" || isLy.substr(-2,isLy.length -1) == "空余"){
  100. let sql = "select `id` from MJ_yp_position_status where positionAndStatus = '" + isLy + "' limit 1"
  101. repostCurd('sql',sql).then(response=>{
  102. cfwz = response.variables.data[0].id
  103. ypInfoList[yp].liu_yang_wei_zhi_ = cfwz
  104. console.log('?question time')
  105. })
  106. }else{
  107. cfwz = ypInfoList[yp].liu_yang_wei_zhi_
  108. }
  109. }else{
  110. if(ypInfoList[yp].shou_yang_wei_zhi == null || ypInfoList[yp].shou_yang_wei_zhi == ''){
  111. this_.$message.error("你正常收样的话,样品存放位置不能为空哦!")
  112. return;
  113. }
  114. if(ypInfoList[yp].liu_yang_wei_zhi_ != undefined && ypInfoList[yp].liu_yang_wei_zhi_ != ''){
  115. this_.$message.error("你正常收样的话,就不要选择留样存放位置!")
  116. return;
  117. }
  118. let isZC = ypInfoList[yp].shou_yang_wei_zhi
  119. if(isZC.substr(-2,isZC.length -1) == "占用" || isZC.substr(-2,isZC.length -1) == "空余"){
  120. let sql = "select `id` from MJ_yp_position_status where positionAndStatus = '" + isZC + "' limit 1"
  121. repostCurd('sql',sql).then(response=>{
  122. cfwz = response.variables.data[0].id
  123. ypInfoList[yp].shou_yang_wei_zhi = cfwz
  124. console.log('?question time')
  125. })
  126. }else{
  127. cfwz = ypInfoList[yp].shou_yang_wei_zhi
  128. }
  129. }
  130. dWhere.push('{"id_":"' + cfwz + '"}')
  131. ypbh.push(ypInfoList[yp].yang_pin_bian_hao)
  132. uuidList.push(ypInfoList[yp].biao_zhi_uuid_)
  133. cfwzIdList.push(cfwz)
  134. ypIdList.push('{"id_":"' + ypInfoList[yp].id_ + '"}')
  135. ypWeiZhi.push(ypInfoList[yp].shou_yang_wei_zhi) // 收样存放位置
  136. ypLiuYangWeiZhi.push(ypInfoList[yp].liu_yang_wei_zhi_) // 留样存放位置
  137. saoMaNumList.push(ypInfoList[yp].jie_yang_shu_lian) // 扫码数量
  138. jieYangQueRenZTList.push(ypInfoList[yp].jie_yang_zhuang_t) // 接收确认状态
  139. ypbhList.push('{"yang_pin_bian_hao":"' + ypInfoList[yp].yang_pin_bian_hao + '"}') // 样品编号列表
  140. }
  141. for(let index in ypIdList){
  142. let WZtem = ypWeiZhi[index]==null?'':ypWeiZhi[index]
  143. let LYWZtem = ypLiuYangWeiZhi[index]==null?'':ypLiuYangWeiZhi[index]
  144. changeWeizhi = WZtem;
  145. changesyWeizhi = LYWZtem;
  146. repostCurd('update','{"tableName":"t_mjypdjb","paramWhere":'+ypIdList[index]+',"paramCond":'+'{"shou_yang_wei_zhi":"'+WZtem+'","jie_yang_shu_lian":"'+saoMaNumList[index]+'","jie_yang_zhuang_t":"'+jieYangQueRenZTList[index]+'","liu_yang_wei_zhi_":"'+ LYWZtem + '"}}')
  147. }
  148. for(let num in dWhere){
  149. if(this.OriginalPosition[num] != cfwzIdList[num]){
  150. let sql = "select * from t_mjypcfwz where id_ = '" + cfwzIdList[num] + "'"
  151. repostCurd('sql',sql).then(response=>{
  152. let resArr = response.variables.data
  153. if(resArr.length == 1){
  154. if(resArr[0].wei_zhi_zhuang_ta == "空余"){
  155. repostCurd('update','{"tableName":"t_mjypcfwz","paramWhere":'+dWhere[num]+',"paramCond":'+'{"wei_zhi_zhuang_ta":"占用","yang_pin_bian_hao":"'+ ypbh[num] + '","ru_ku_shi_jian_":"'+ this_.dateFormat() + '","shou_yang_ri_qi_":"'+ uuidList[num] + '"}}')
  156. }else if(resArr[0].wei_zhi_zhuang_ta == "占用"){
  157. // 新增一条新的位置记录,使用旧的位置记录 修改它的样品编号,入库时间,标识UUID
  158. let cfNewList = []
  159. let cfNew = {}
  160. cfNew["fang_jian_lei_xin"] = resArr[0].fang_jian_lei_xin
  161. cfNew["huo_jia_lei_xing_"] = resArr[0].huo_jia_lei_xing_
  162. cfNew["huo_jia_hao_"] = resArr[0].huo_jia_hao_
  163. cfNew["qu_yu_"] = resArr[0].qu_yu_
  164. cfNew["gua_jia_hao_"] = resArr[0].gua_jia_hao_
  165. cfNew["ceng_hao_"] = resArr[0].ceng_hao_
  166. cfNew["wei_zhi_bian_hao_"] = resArr[0].wei_zhi_bian_hao_
  167. cfNew["wei_zhi_zhuang_ta"] = resArr[0].wei_zhi_zhuang_ta
  168. cfNew["cun_fang_lei_xing"] = resArr[0].cun_fang_lei_xing
  169. cfNew["cun_chu_tiao_jian"] = resArr[0].cun_chu_tiao_jian
  170. cfNew["yang_pin_bian_hao"] = ypbh[num]
  171. cfNew["ru_ku_shi_jian_"] = this_.dateFormat()
  172. cfNew["shou_yang_ri_qi_"] = uuidList[num]
  173. cfNewList.push(cfNew)
  174. let uuid = cfNew["shou_yang_ri_qi_"];
  175. repostCurd('add', '{"tableName":"t_mjypcfwz","paramWhere":' + JSON.stringify(cfNewList) + '}').then(res => {
  176. let selectsql = "select id_ from t_mjypcfwz where shou_yang_ri_qi_='" + uuid + "'";
  177. repostCurd('sql', selectsql).then(res => {
  178. let dataid = res.variables.data[0].id_;
  179. // console.log(res.variables.data)
  180. let abc = '{"biao_zhi_uuid_":"' + uuid + '"}'
  181. // console.log('zzj abc ',abc)
  182. if (changeWeizhi && !changesyWeizhi) {
  183. repostCurd('update', '{"tableName":"t_mjypdjb","paramWhere":' + abc + ',"paramCond":' + '{"shou_yang_wei_zhi":"' + dataid + '"}}').then(res => {
  184. })
  185. } else {
  186. repostCurd('update', '{"tableName":"t_mjypdjb","paramWhere":' + abc + ',"paramCond":' + '{"liu_yang_wei_zhi_":"' + dataid + '"}}').then(res => {
  187. })
  188. }
  189. })
  190. })
  191. }
  192. }
  193. })
  194. }
  195. }
  196. repostCurd('selects','{"tableName":"t_mjypb","paramWhere":['+ypbhList+']}').then(response=>{
  197. mjypbList = response.variables.data
  198. let wjList = []
  199. let wjAll = []
  200. let wjAllList = []
  201. for(let i in mjypbList){
  202. wjList.push(mjypbList[i].wai_jian_)
  203. wjAll.push(mjypbList[i].wai_jian_)
  204. }
  205. wjList = this_.unique(wjList)
  206. for(let i in wjList){
  207. mjypbWJ.push('{"id_":"' + wjList[i]+ '"}')
  208. }
  209. for(let i in wjAll){
  210. wjAllList.push('{"id_":"' + wjAll[i]+ '"}')
  211. }
  212. repostCurd('updates','{"tableName":"t_mjwtsqb","paramWhere":['+mjypbWJ+'],"paramCond":{"zhuang_tai_":"委托结束"}}')
  213. let mjwtsqbAllResult = []
  214. let mjwtsqbIdList = []
  215. let mjfbbList = []
  216. let mjfbbWJList = []
  217. for(let i in wjAllList){
  218. repostCurd('select','{"tableName":"t_mjwtsqb","paramWhere":'+wjAllList[i]+'}').then(response=>{
  219. mjfbbWJList.push('{"wei_tuo_wai_jian_":"' + response.variables.data[0].id_ + '"}')
  220. mjwtsqbAllResult.push(response.variables.data[0])
  221. mjwtsqbIdList.push('{"id_":"' + response.variables.data[0].id_ + '"}')
  222. })
  223. }
  224. setTimeout(()=>{
  225. let narr = []
  226. for(let a of mjfbbWJList){
  227. narr.push(a)
  228. }
  229. repostCurd('selects','{"tableName":"t_mjfbb","paramWhere":['+narr+']}').then(response=>{
  230. mjfbbList.push(response.variables.data)
  231. })
  232. }, 1000)
  233. setTimeout(()=>{
  234. /* 分包
  235. repostCurd('select','{"tableName":"t_mjfbb","paramWhere":'+mjwtsqbIdList[i]+'}').then(response=>{
  236. console.log(response.variables.data)
  237. mjfbbList.push(response.variables.data)
  238. })*/
  239. let rwb = []
  240. let index = 0
  241. if(mjypbList != null && mjypbList.length >= 1){
  242. index = mjypbList[0].jian_ce_xiang_mu2.split(",").length - 1
  243. }
  244. for(var i in mjypbList){
  245. // console.log('坐标',i,p)
  246. let rwzb = {}
  247. let wz_ = ypInfoList[i].shi_fou_liu_yang_ == "是" ? ypInfoList[i].liu_yang_wei_zhi_ : ypInfoList[i].shou_yang_wei_zhi // 对应的样品存放位置
  248. rwzb["yang_pin_bian_hao"] = mjypbList[i].yang_pin_bian_hao // 取对应的样品编号
  249. rwzb["yang_pin_ming_che"] = mjypbList[i].yang_pin_ming_che // 对应的样品名称
  250. rwzb["yang_pin_dai_ci_"] = mjypbList[i].dai_ci_ // 对应的样品代次
  251. rwzb["yang_pin_pi_hao_"] = mjypbList[i].pi_hao_ // 对应的样品批号
  252. rwzb["yang_pin_shu_lian"] = mjypbList[i].shu_liang_ // 对应的样品数量
  253. rwzb["bug_ri_qi_"] = mjypbList[i].song_yang_ri_qi_ // 对应的送样日期
  254. rwzb["cun_fang_wei_zhi_"] = wz_
  255. rwzb["wei_tuo_wai_jian_"] = mjypbList[i].wai_jian_ // 检测申请单id
  256. rwzb["he_tong_wai_jian_"] = mjwtsqbAllResult[i].he_tong_bian_hao_ //合同id
  257. rwzb["song_yang_ri_qi_"] = mjypbList[i].biao_zhi_uuid_ // 收样日期
  258. rwzb["wei_tuo_ren_"] = mjwtsqbAllResult[i].lian_xi_ren_ // 委托人
  259. rwzb["bao_gao_jian_ce_s"] = this_.dateFormat() // 检测时间
  260. rwzb["zhan_shi_biao_wai"] = mjwtsqbAllResult[i].ye_mian_zong_zhua
  261. rwzb["zhuang_tai_"] = "任务待分配" // 状态
  262. rwzb["gong_xian_zhi_"] = mjypbList[i].yang_pin_lei_xin // 供限值
  263. rwzb["yang_pin_bei_zhu_"] = mjypbList[i].bei_zhu_ // 样品备注
  264. rwb.push(rwzb)
  265. // let str = mjypbList[i].jian_ce_xiang_mu2.split(",")
  266. // for (var p in str) {
  267. // // console.log('坐标',i,p)
  268. // let temp = index - p
  269. // let rwzb = {}
  270. // let wz_ = ypInfoList[i].shi_fou_liu_yang_ == "是" ? ypInfoList[i].liu_yang_wei_zhi_ : ypInfoList[i].shou_yang_wei_zhi // 对应的样品存放位置
  271. // rwzb["jian_ce_xiang_mu_"] = str[p] // 取当前检测项目
  272. // rwzb["yang_pin_bian_hao"] = mjypbList[i].yang_pin_bian_hao // 取对应的样品编号
  273. // rwzb["yang_pin_ming_che"] = mjypbList[i].yang_pin_ming_che // 对应的样品名称
  274. // rwzb["yang_pin_dai_ci_"] = mjypbList[i].dai_ci_ // 对应的样品代次
  275. // rwzb["yang_pin_pi_hao_"] = mjypbList[i].pi_hao_ // 对应的样品批号
  276. // rwzb["yang_pin_shu_lian"] = mjypbList[i].shu_liang_ // 对应的样品数量
  277. // rwzb["bug_ri_qi_"] = mjypbList[i].song_yang_ri_qi_ // 对应的送样日期
  278. // rwzb["cun_fang_wei_zhi_"] = wz_
  279. // rwzb["wei_tuo_wai_jian_"] = mjypbList[i].wai_jian_ // 检测申请单id
  280. // rwzb["he_tong_wai_jian_"] = mjwtsqbAllResult[i].he_tong_bian_hao_ //合同id
  281. // rwzb["song_yang_ri_qi_"] = mjypbList[i].biao_zhi_uuid_ // 收样日期
  282. // rwzb["wei_tuo_ren_"] = mjwtsqbAllResult[i].lian_xi_ren_ // 委托人
  283. // rwzb["bao_gao_jian_ce_s"] = this_.dateFormat() // 检测时间
  284. // rwzb["zhan_shi_biao_wai"] = mjwtsqbAllResult[i].ye_mian_zong_zhua
  285. // rwzb["zhuang_tai_"] = "任务待分配" // 状态
  286. // rwzb["shi_fou_fen_bao_"] = mjfbbList[0][temp].shi_fou_fen_bao_ // 是否分包
  287. // rwzb["qi_wang_wan_cheng"] = mjfbbList[0][temp].wan_cheng_shi_jia // 期望完成时间
  288. // rwzb["gong_xian_zhi_"] = mjypbList[i].yang_pin_lei_xin // 供限值
  289. // rwb.push(rwzb)
  290. // }
  291. // index += str.length
  292. }
  293. repostCurd('updates', '{"tableName":"t_mjwtsqb","paramWhere":['+mjwtsqbIdList+'],"paramCond":{"jian_ce_kai_shi_s":"' + this_.dateFormat() + '"}}')
  294. let uidList = []
  295. for(let item of mjwtsqbAllResult){
  296. uidList.push(item.ye_mian_zong_zhua)
  297. }
  298. uidList = this_.unique(uidList)
  299. repostCurd('add', '{"tableName":"t_rwfpb","paramWhere":'+JSON.stringify(rwb)+',"defKey":"Process_04tgh24","formKey":"mjrwfp"}' )
  300. if(uidList.length > 0 ){
  301. let ups = []
  302. for(let t of uidList){
  303. ups.push('{"shen_qing_id_":"'+t+'"}')
  304. }
  305. repostCurd('updates', '{"tableName":"t_mjwtzsb","paramWhere":['+ups+'],"paramCond":{"zhuang_tai_":"任务分配进行中"}}')
  306. }
  307. },2000)
  308. })
  309. this.$emit('callback',true)
  310. this.visable = false
  311. this.$message({
  312. message:'样品接收确认操作成功!',
  313. type:'success'
  314. })
  315. this.closeDialog();
  316. }).catch(_ => {});
  317. },
  318. /* 去除指定行数据 使用过滤器filter过滤指定行号数据 */
  319. deleteData(val){
  320. this.listData = this.listData.filter((data) =>{
  321. return data.id_!=val
  322. })
  323. },
  324. unique(arr) {
  325. return arr.filter((item, index) => {
  326. return arr.indexOf(item, 0) === index;
  327. });
  328. },
  329. Update (name,where,cond) {
  330. let cont = {}
  331. cont['tableName'] = name
  332. cont['paramWhere'] = where
  333. cont['paramCond'] = cond
  334. return repostCurd('update',JSON.stringify(cont))
  335. },
  336. /* zzj add */
  337. dateFormat() { // 获取当前时间
  338. var date=new Date();
  339. var year=date.getFullYear();
  340. var month= date.getMonth()+1<10 ? "0"+(date.getMonth()+1) : date.getMonth()+1;
  341. var day=date.getDate()<10 ? "0"+date.getDate() : date.getDate();
  342. return year+"-"+month+"-"+day;
  343. },
  344. /* 关闭*/
  345. remRedar() {
  346. this.visible = false // 列表隐藏
  347. this.listData = [] // 清空列表数据
  348. this.redar = false // 扫码图标隐藏
  349. this.$emit('scanOff',false)
  350. },
  351. }
  352. }