赫艾前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

396 lines
13 KiB

  1. <script>
  2. import {getPartValue, removeScanLabel, saveScanLabel, scanLabel} from "../../../api/production/generateReport";
  3. import dayjs from "dayjs";
  4. import {Decimal} from "decimal.js";
  5. import {getPhotoAddressData} from "../../../api/pad";
  6. export default {
  7. name:"scanForm",
  8. props:{
  9. detail:{
  10. type: [Object],
  11. required: true
  12. },
  13. scanFlag:{
  14. type: Boolean,
  15. default:false,
  16. },
  17. allNum:{
  18. type:Number,
  19. default: 0,
  20. },
  21. notifyQty:{
  22. type:Number,
  23. default:0,
  24. },
  25. isReport:{
  26. type:Boolean,
  27. default:false,
  28. }
  29. },
  30. computed:{
  31. flag:{
  32. get(){
  33. return this.scanFlag;
  34. },
  35. set(val){
  36. this.$emit("update:scanFlag",val)
  37. }
  38. },
  39. total:{
  40. get(){
  41. return this.scanLabelDetailList.reduce((pre, cur) => {
  42. return pre + new Decimal(cur.scanQty).toNumber()
  43. }, 0);
  44. },
  45. set(val) {
  46. // this.scanLabelDetailList = v
  47. }
  48. },
  49. totalNum:{
  50. get(){
  51. return this.scanLabelDetailList.length;
  52. },
  53. set(val) {
  54. // this.scanLabelDetailList = v
  55. }
  56. },
  57. totalWeight:{
  58. get(){
  59. return this.scanLabelDetailList.reduce((pre, cur) => {
  60. if (cur.weight){
  61. return pre + new Decimal(cur.weight).toNumber()
  62. }
  63. return pre
  64. }, 0);
  65. },
  66. set(val) {
  67. }
  68. }
  69. },
  70. data(){
  71. return{
  72. model:{
  73. flag:"",
  74. label:'',
  75. },
  76. partValue:0,
  77. scanLabelDetailList:[],
  78. photoDatas:[],
  79. num:1,
  80. exportDataStandard: {
  81. "通知单号": "delNotifyNo",
  82. "通知单序号号": "delNotifyItemNo",
  83. "产品编码": "partNo",
  84. "数量": "scanQty",
  85. "类型": "scanType",
  86. "JOB NO.": "seqNo",
  87. "操作员": "createBy",
  88. "扫描时间": "createData",
  89. },
  90. exportName: "发货扫描"+dayjs().format("YYYYMMDDHHmmss"),
  91. }
  92. },
  93. methods:{
  94. removeScanLabel(row){
  95. removeScanLabel(row).then(({data})=>{
  96. if (data && data.code === 0){
  97. this.$message.success(data.msg)
  98. this.scanLabel();
  99. }else {
  100. this.$message.warning(data.msg)
  101. }
  102. }).catch((error)=>{
  103. this.$message.error(error)
  104. })
  105. },
  106. getFocus(refName){
  107. this.$refs[refName].focus()
  108. },
  109. openScanDialog(){
  110. this.getFocus('focusInput')
  111. // 获取当前part的 标准标签数量
  112. let params={
  113. site:this.detail.site,
  114. partNo:this.detail.partNo
  115. }
  116. getPartValue(params).then(({data})=>{
  117. if (data && data.code === 0){
  118. this.partValue = data.data;
  119. }else {
  120. this.$message.warning(data.msg)
  121. }
  122. }).catch((error)=>{
  123. this.$message.error(error)
  124. })
  125. },
  126. scanLabel(){
  127. let paramsScan={
  128. site:this.detail.site,
  129. delNotifyNo: this.detail.delNotifyNo,
  130. delNotifyItemNo: this.detail.delNotifyItemNo,
  131. }
  132. scanLabel(paramsScan).then(({data})=>{
  133. if (data && data.code === 0){
  134. this.scanLabelDetailList = data.rows;
  135. this.$emit("changeAllNum",this.total)
  136. }else {
  137. this.$message.warning(data.msg)
  138. }
  139. }).catch((error)=>{
  140. this.$message.error(error)
  141. })
  142. this.getPhoto();
  143. },
  144. scanLabelEnter(){
  145. if (this.total > this.notifyQty){
  146. this.$message.warning("扫描累计数量不允许超过要求发货数量")
  147. return;
  148. }
  149. let arr = this.model.label.split(";");
  150. if (arr.length < 5){//site;partNo;qty;seqNo;printId
  151. if (!arr[3]){
  152. this.$message.warning("标签jobNo为空")
  153. return;
  154. }
  155. if (!arr[2] || arr[2] === '0'){
  156. this.$message.warning("数量不存在或是0")
  157. return;
  158. }
  159. if (!arr[1]){
  160. this.$message.warning("产品编码为空")
  161. return;
  162. }
  163. if (!arr[0]){
  164. this.$message.warning("site编码为空")
  165. return;
  166. }
  167. this.$message.warning("标签格式错误")
  168. return
  169. }
  170. if (arr[0] !== this.detail.site || arr[1] !== this.detail.partNo){
  171. this.$message.warning(`产品不匹配或每袋/每卷数量未维护`)
  172. return;
  173. }
  174. if (this.partValue===0){
  175. this.$message.warning(`每袋/每卷数量未维护`)
  176. return;
  177. }
  178. // if (this.model.flag !== 'Y' && this.partValue != arr[2]){
  179. // this.$message.warning(`标签数量与标准袋装数量不匹配`)
  180. // return;
  181. // }
  182. if (new Decimal(this.total).add(new Decimal(arr[2])).toNumber()> this.notifyQty){
  183. this.$message.warning("扫描累计数量不允许超过要求发货数量")
  184. return;
  185. }// 保存数据 通知单数量:this.detail.notifyQty
  186. let params={
  187. site:this.detail.site,
  188. delNotifyNo: this.detail.delNotifyNo,
  189. delNotifyItemNo: this.detail.delNotifyItemNo,
  190. scanQty:arr[2],
  191. scanType:parseInt(arr[2]) !== this.partValue?'零散数量':'标准数量',
  192. seqNo:arr[3],
  193. printId:arr[4]?arr[4]:'',
  194. weight:arr[5],
  195. createBy:this.$store.state.user.name,
  196. createData:dayjs().format("YYYY-MM-DD")
  197. }
  198. saveScanLabel(params).then(({data})=>{
  199. if (data && data.code === 0){
  200. this.$message.success(data.msg)
  201. this.scanLabel();
  202. }else {
  203. this.$message.warning(data.msg)
  204. }
  205. // 重置标签
  206. this.model.flag = "";
  207. this.model.label = '';
  208. }).catch((error)=>{
  209. this.$message.warning(error)
  210. this.model.flag = "";
  211. this.model.label = '';
  212. })
  213. },
  214. closeScanDialog(){
  215. this.model = {
  216. label: '',
  217. flag: '',
  218. }
  219. if (this.isReport === false && this.total < this.notifyQty){
  220. this.$message.warning("扫描数量未达到通知单数量")
  221. // this.$alert("扫描数量未达到通知单数量", '提示', {
  222. // confirmButtonText: '确定',
  223. // });
  224. }
  225. this.scanLabelDetailList = [];
  226. },
  227. getPhoto(){
  228. let params = {
  229. site:this.detail.site,
  230. partNo:this.detail.partNo,
  231. }
  232. this.photoDatas = [];
  233. this.num=1;
  234. getPhotoAddressData(params).then(({data}) => {
  235. this.photoDatas = data.rows;
  236. if(this.photoDatas.length===0){
  237. setTimeout(() => {
  238. this.$alert('该物料没有上传图片!', '错误', {
  239. confirmButtonText: '确定'
  240. })
  241. }, 500);
  242. return false;
  243. }
  244. })
  245. },
  246. lastPicture(){
  247. this.$refs.photoCarousel.prev();
  248. },
  249. nextPicture(){
  250. this.$refs.photoCarousel.next();
  251. },
  252. changePhoto(index){
  253. this.num=index+1;
  254. }
  255. }
  256. }
  257. </script>
  258. <template>
  259. <div>
  260. <el-dialog
  261. title="出货扫描" v-drag
  262. :visible.sync="flag"
  263. width="80%"
  264. @open="scanLabel"
  265. @close="closeScanDialog" @opened="openScanDialog">
  266. <div style="display:flex;justify-content:space-between;align-items:flex-start;">
  267. <div style="width: 60%">
  268. <el-form :model="model" :inline="true" label-position="top">
  269. <!-- <el-form-item label=" ">-->
  270. <!-- <el-select v-model="model.flag" clearable>-->
  271. <!-- <el-option value="" label="标准袋数"></el-option>-->
  272. <!-- <el-option value="Y" label="零数袋"></el-option>-->
  273. <!-- </el-select>-->
  274. <!-- </el-form-item>-->
  275. <el-form-item label="标签" style="width: 200px " v-if="!isReport">
  276. <el-input ref="focusInput" v-model="model.label" @keyup.enter.native="scanLabelEnter"></el-input>
  277. </el-form-item>
  278. <el-form-item label="合计">
  279. <el-input-number disabled :controls="false" style="margin-top: -5px;text-align: right" v-model="total"></el-input-number>
  280. </el-form-item>
  281. <el-form-item label="袋数">
  282. <el-input-number disabled :controls="false" style="margin-top: -5px;text-align: right" v-model="totalNum"></el-input-number>
  283. </el-form-item>
  284. <el-form-item label="总重量">
  285. <el-input-number disabled :controls="false" style="margin-top: -5px;text-align: right" v-model="totalWeight"></el-input-number>
  286. </el-form-item>
  287. <el-form-item label=" " v-if="isReport">
  288. <download-excel
  289. :fields="exportDataStandard"
  290. :data="scanLabelDetailList.map(item=>{item.partNo=detail.partNo;return item;})"
  291. type="xlsx"
  292. :name="exportName"
  293. worksheet="导出信息"
  294. class="el-button el-button--primary el-button--medium">
  295. 导出
  296. </download-excel>
  297. </el-form-item>
  298. </el-form>
  299. <el-table :data="scanLabelDetailList" stripe border height="500" highlight-current-row>
  300. <el-table-column label="操作" align="center" v-if="!isReport">
  301. <template slot-scope="{row,$index}">
  302. <el-link style="cursor:pointer;" @click="removeScanLabel(row)">删除</el-link>
  303. </template>
  304. </el-table-column>
  305. <el-table-column label="通知单号" min-width="120px" header-align="center" align="center" show-overflow-tooltip prop="delNotifyNo"/>
  306. <el-table-column label="通知单号序号" min-width="100px" header-align="center" align="left" show-overflow-tooltip prop="delNotifyItemNo"/>
  307. <el-table-column label="产品编码" min-width="100px" header-align="center" show-overflow-tooltip>
  308. <template slot-scope="{row,$index}">
  309. {{detail.partNo}}
  310. </template>
  311. </el-table-column>
  312. <el-table-column label="数量" min-width="60px" header-align="center" align="center" show-overflow-tooltip prop="scanQty"/>
  313. <el-table-column label="重量" min-width="60px" header-align="center" align="center" show-overflow-tooltip prop="weight"/>
  314. <el-table-column label="类型" min-width="100px" header-align="center" align="center" show-overflow-tooltip prop="scanType"/>
  315. <el-table-column label="JOB NO." min-width="100px" header-align="center" align="left" show-overflow-tooltip prop="seqNo"/>
  316. <el-table-column label="序号" min-width="100px" header-align="center" align="left" show-overflow-tooltip prop="printId"/>
  317. <el-table-column label="操作员" min-width="100px" header-align="center" align="left" show-overflow-tooltip prop="createBy"/>
  318. <el-table-column label="扫描时间" min-width="100px" header-align="center" align="center" show-overflow-tooltip prop="createData"/>
  319. </el-table>
  320. </div>
  321. <div class="photo" style="width: 40%;padding-left: 10px">
  322. <el-form label-position="top" size="medium">
  323. <el-row :gutter="20">
  324. <el-col :span="8">
  325. <el-form-item label="产品编码:">
  326. <el-input v-model="detail.partNo" readonly></el-input>
  327. </el-form-item>
  328. </el-col>
  329. <el-col :span="10">
  330. <el-form-item style="height: 30px;" label=" ">
  331. <div>
  332. <el-button @click="lastPicture()" style="height: 30px;width: 80px" type="primary">
  333. 上一张
  334. </el-button>
  335. <el-button @click="nextPicture()" style="height: 30px;width: 80px" type="primary">
  336. 下一张
  337. </el-button>
  338. </div>
  339. </el-form-item>
  340. </el-col>
  341. </el-row>
  342. <el-row :gutter="20">
  343. <el-col :span="18">
  344. <el-form-item :label="`文件名(${photoDatas[this.num-1]?this.num:0}/${this.photoDatas.length})`">
  345. <el-input :value="photoDatas[this.num-1]?photoDatas[this.num-1].attaFileNameDb:''" readonly></el-input>
  346. </el-form-item>
  347. </el-col>
  348. </el-row>
  349. </el-form>
  350. <div id="padPhoto" style="text-align: center;width: 100%;vertical-align:middle;margin-top: 5px">
  351. <el-carousel height="400px" @change="changePhoto" ref="photoCarousel" :autoplay="false" indicator-position="none" :interval="5000" arrow="never">
  352. <el-carousel-item v-for="(item,index) in this.photoDatas" :key="index">
  353. <img style="max-width:100%;height: 400px;object-fit: cover;object-position: center center" :src="$store.state.user.padSopUrl+item.attaFileNameDb">
  354. </el-carousel-item>
  355. </el-carousel>
  356. </div>
  357. </div>
  358. </div>
  359. <div style="height: 20px"></div>
  360. </el-dialog>
  361. </div>
  362. </template>
  363. <style scoped>
  364. .el-input-number /deep/ .el-input__inner{
  365. text-align: left;
  366. margin-top: 5px;
  367. padding-right: 5px !important;
  368. padding-left: 5px !important;
  369. }
  370. .photo .el-form-item--medium /deep/ .el-form-item__label {
  371. font-size: 16px;
  372. line-height: 30px;
  373. height: 30px;
  374. }
  375. .photo .el-form-item--medium /deep/ .el-form-item__content {
  376. margin-bottom: 5px;
  377. }
  378. .photo .el-form-item--medium /deep/ .el-form-item__content .el-button {
  379. width: 80px;
  380. height: 30px;
  381. }
  382. .photo .el-form-item--medium /deep/ .el-form-item__content .el-input .el-input__inner {
  383. font-size: 16px;
  384. line-height: 30px;
  385. height: 30px !important;
  386. }
  387. </style>