edit.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <div class="ele-body">
  4. <el-card shadow="never">
  5. <header-title>
  6. <el-button @click="cancel">返回</el-button>
  7. <el-button type="primary" @click="submit" :loading="loading">提交</el-button>
  8. </header-title>
  9. <base-info ref="baseInfoRefs" v-if="baseForm" :form="baseForm" :btnType="btnType"></base-info>
  10. <ele-pro-table ref="table" :columns="tableColumns" :datasource="datasource" :pageSize="20"
  11. :pageSizes="[20, 30, 40, 50, 100]">
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. </template>
  15. <template v-slot:categoryCode="{ row }">
  16. <el-link type="primary" :underline="false">
  17. {{ row.categoryCode }}
  18. </el-link>
  19. </template>
  20. <!-- 操作列 -->
  21. <template v-slot:action="{ row }">
  22. <el-link type="primary" :underline="false" @click="handleDispose(row, 'dispose')">
  23. 处置
  24. </el-link>
  25. </template>
  26. </ele-pro-table>
  27. <!-- <template v-slot:footer>-->
  28. <!-- <el-button @click="handleClose">取消</el-button>-->
  29. <!-- </template>-->
  30. <!-- </ele-modal>-->
  31. </el-card>
  32. <sampleDisposeDialog ref="disposeRef" @handleDisposeConfirm="handleDisposeConfirm"></sampleDisposeDialog>
  33. </div>
  34. </template>
  35. <script>
  36. import { getSampleQWorkOrderIdPage, getById, disposeSubmit } from "@/api/samplemanagement";
  37. import baseInfo from './baseInfo.vue';
  38. import { finishPageTab } from "@/utils/page-tab-util";
  39. import sampleDisposeDialog from '@/views/inspectionWork/components/sampleDisposeDialog.vue';
  40. export default {
  41. components: {
  42. baseInfo,
  43. sampleDisposeDialog
  44. },
  45. data() {
  46. const defaultForm = function () {
  47. return {
  48. };
  49. };
  50. return {
  51. defaultForm,
  52. // 表单数据
  53. baseForm: { ...defaultForm() },
  54. title: null,
  55. btnType: null,
  56. visible: false,
  57. loading: false,
  58. qualityWorkOrderId: '',
  59. qualitySampleList: [],
  60. tableColumns: [
  61. { label: '编码', prop: 'categoryCode', width: '150', align: 'center', showOverflowTooltip: true, slot: 'categoryCode' },
  62. { label: '名称', prop: 'categoryName', width: '150', align: 'center', showOverflowTooltip: true },
  63. { label: '批次号', prop: 'batchNo', align: 'center', showOverflowTooltip: true },
  64. { label: '发货条码', prop: 'barcodes', align: 'center', showOverflowTooltip: true },
  65. { label: '包装编码', prop: 'packageNo', align: 'center', showOverflowTooltip: true },
  66. { label: '包装数量', prop: 'packingQuantity', align: 'center', showOverflowTooltip: true },
  67. { label: '包装单位', prop: 'packingUnit', align: 'center', showOverflowTooltip: true },
  68. { label: '计量数量', prop: 'measureQuantity', align: 'center', showOverflowTooltip: true },
  69. { label: '计量单位', prop: 'measureUnit', align: 'center', showOverflowTooltip: true },
  70. { label: '物料代号', prop: 'materielDesignation', align: 'center', showOverflowTooltip: true },
  71. { label: '客户代号', prop: 'clientCode', align: 'center', showOverflowTooltip: true },
  72. { label: '刻码', prop: 'engrave', align: 'center', showOverflowTooltip: true },
  73. { label: '仓库', prop: 'warehouseName', align: 'center', showOverflowTooltip: true },
  74. { label: '货区', prop: 'areaName', align: 'center', showOverflowTooltip: true },
  75. { label: '货架', prop: 'goodsShelfName', align: 'center', showOverflowTooltip: true },
  76. { label: '货位', prop: 'goodsAllocationName', align: 'center', showOverflowTooltip: true },
  77. { label: '生产日期', prop: 'productionDate', align: 'center', showOverflowTooltip: true },
  78. { label: '采购日期', prop: 'purchaseDate', align: 'center', showOverflowTooltip: true },
  79. { label: '重量', prop: 'weight', align: 'center', showOverflowTooltip: true, fixed: 'right' },
  80. { label: '重量单位', prop: 'weightUnit', align: 'center', showOverflowTooltip: true, fixed: 'right' },
  81. {
  82. label: '处置状态', prop: 'disposalStatus', align: 'center', showOverflowTooltip: true, fixed: 'right', formatter: (row, column, cellValue) => {
  83. return cellValue == 1 ? '返工' : cellValue == 2 ? '返修' : cellValue == 3 ? '报废' : cellValue == 4 ? '降级使用' :
  84. cellValue == 5 ? '让步接收' : cellValue == 6 ? '留样' : cellValue == 7 ? '消耗' : cellValue == 8 ? '回用' : '';
  85. }
  86. },
  87. { label: '处置时间', prop: 'disposeTime', align: 'center', showOverflowTooltip: true, fixed: 'right' },
  88. {
  89. label: '质检状态', prop: 'qualityStatus', align: 'center', showOverflowTooltip: true, fixed: 'right', formatter: (row, column, cellValue) => {
  90. return cellValue == 0 ? '未检' : cellValue == 1 ? '已检' : cellValue == 2 ? '待检' : '';
  91. }
  92. },
  93. {
  94. label: '质检结果', prop: 'qualityResults', align: 'center', showOverflowTooltip: true, fixed: 'right', formatter: (row, column, cellValue) => {
  95. return cellValue == 1 ? '合格' : cellValue == 2 ? '不合格' : '';
  96. }
  97. },
  98. { columnKey: 'action', label: '操作', align: 'center', width: 120, resizable: false, slot: 'action', fixed: 'right' }
  99. ],
  100. tableData: []
  101. };
  102. },
  103. computed: {
  104. },
  105. watch: {
  106. },
  107. created() {
  108. if (this.$route.query.id) {
  109. this.getDetail();
  110. }
  111. },
  112. methods: {
  113. async datasource({ page, where, limit }) {
  114. where.qualityWorkOrderId = this.$route.query.qualityWorkOrderId;
  115. const arr = await getSampleQWorkOrderIdPage({
  116. ...where,
  117. pageNum: page,
  118. size: limit
  119. });
  120. this.tableData = arr.list;
  121. console.log(arr, 'arr')
  122. return arr.list;
  123. },
  124. async getDetail() {
  125. this.visible = true;
  126. this.qualityWorkOrderId = this.$route.query.qualityWorkOrderId;
  127. getById(this.$route.query.id).then(res => {
  128. this.btnType = this.$route.query.type;
  129. console.log(res, 'res.data');
  130. this.baseForm = res.data;
  131. });
  132. },
  133. async open(type, row) {
  134. this.btnType = type;
  135. this.title = type == 'add' ? '新增' : type == 'edit' ? '编辑' : '详情';
  136. if (this.btnType != 'add') {
  137. this.qualityWorkOrderId = row.qualityWorkOrderId;
  138. this.baseForm = JSON.parse(JSON.stringify(row));
  139. }
  140. this.visible = true;
  141. },
  142. resetForm() {
  143. this.baseForm = { ...this.defaultForm() };
  144. },
  145. handleClose() {
  146. this.resetForm();
  147. // this.resetTable();
  148. this.visible = false;
  149. },
  150. cancel() {
  151. finishPageTab();
  152. this.$router.go(-1);
  153. },
  154. async submit() {
  155. console.log(this.tableData, '表格');
  156. for (let i = 0; i < this.tableData.length; i++) {
  157. const disposalStatus = this.tableData[i].disposalStatus;
  158. const disposeTime = this.tableData[i].disposeTime;
  159. const qualityStatus = this.tableData[i].qualityStatus;
  160. if (disposalStatus == null || disposeTime == null) {
  161. this.$message.error('请完善处置状态和处置时间!')
  162. this.loading = false;
  163. return
  164. }
  165. if (qualityStatus == '2') {
  166. this.$message.error('请完善质检状态!')
  167. this.loading = false;
  168. return
  169. }
  170. }
  171. this.loading = true;
  172. let pData = {
  173. ...form,
  174. qualitySampleUpdatePOList: this.tableData,
  175. }
  176. disposeSubmit(pData)
  177. .then((msg) => {
  178. this.loading = false;
  179. this.$message.success(msg);
  180. this.cancel();
  181. this.$emit('done');
  182. })
  183. .catch((e) => {
  184. this.loading = false;
  185. });
  186. },
  187. handleDispose(row, type) {
  188. row.sampleDate = this.getNowTimes();
  189. row.disposeTime = this.getNowTimes();
  190. console.log(null, row, type, this.$route.query.qualityType)
  191. this.$refs.disposeRef.openDispose(null, row, type, this.$route.query.qualityType);
  192. },
  193. // 处理确认事件
  194. handleDisposeConfirm(row, index) {
  195. console.log(row, index, '处置确认');
  196. },
  197. getNowDate() {
  198. let date = new Date(),
  199. obj = {
  200. year: date.getFullYear(), //获取当前月份(0-11,0代表1月)
  201. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  202. strDate: date.getDate(), // 获取当前日(1-31)
  203. hour: date.getHours(), //获取当前小时(0 ~ 23)
  204. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  205. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  206. };
  207. Object.keys(obj).forEach((key) => {
  208. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  209. });
  210. return obj;
  211. },
  212. getNowTime() {
  213. const nowDate = this.getNowDate()
  214. return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate + ' ' + nowDate.hour + ':' + nowDate.minute + ':' + nowDate.second
  215. },
  216. getNowTimes() {
  217. const nowDate = this.getNowDate()
  218. return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate
  219. },
  220. }
  221. };
  222. </script>
  223. <style lang="scss" scoped>
  224. .location-warp {
  225. display: flex;
  226. .detail {
  227. margin-left: 10px;
  228. }
  229. }
  230. :deep(.el-form-item__content .el-input-group__prepend) {
  231. background-color: #fff;
  232. }
  233. :deep(.el-dialog:not(.ele-dialog-form) .el-dialog__body .el-form .el-form-item:last-child) {
  234. margin-bottom: 22px;
  235. }
  236. .add-product {
  237. width: 100%;
  238. display: flex;
  239. align-items: center;
  240. justify-content: flex-end;
  241. font-size: 30px;
  242. color: #1890ff;
  243. margin: 10px 0;
  244. cursor: pointer;
  245. }
  246. .el-pagination {
  247. padding: 12px 16px;
  248. background: #fff;
  249. border: 1px solid #ebeef5;
  250. border-top: none;
  251. }
  252. </style>