manualConfirmationJS.js 16 KB

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