CheckProduct.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div>
  3. <el-dialog title="京东退货质检" v-model="visible" width="1200px" destroy-on-close :loading="loading">
  4. <el-button type="primary" @click="handleOpen" style="margin-bottom: 10px">
  5. 选择产品
  6. </el-button>
  7. <!-- <el-button type="primary" @click="openExcel" style="margin-bottom: 10px">-->
  8. <!-- 导入Excel-->
  9. <!-- </el-button>-->
  10. <el-table :data="list">
  11. <el-table-column prop="productCustomCode" label="物品编码"/>
  12. <el-table-column prop="productName" label="物品名称"/>
  13. <el-table-column prop="productSpec" label="规格"/>
  14. <el-table-column prop="productUnit" label="单位"/>
  15. <el-table-column prop="quantity" label="待质检数量"/>
  16. <el-table-column label="良品数量" width="120">
  17. <template #default="{ row, $index }">
  18. <el-input-number
  19. v-model="row.qualifiedCount"
  20. :controls="false"
  21. :precision="0"
  22. :min="0"
  23. style="width: 80px"
  24. />
  25. </template>
  26. </el-table-column>
  27. <el-table-column label="次品数量" width="120">
  28. <template #default="{ row, $index }">
  29. <el-input-number
  30. v-model="row.defectiveCount"
  31. :controls="false"
  32. :precision="0"
  33. :min="0"
  34. style="width: 80px"
  35. />
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="报废数量" width="120">
  39. <template #default="{ row, $index }">
  40. <el-input-number
  41. v-model="row.scrappedCount"
  42. :controls="false"
  43. :precision="0"
  44. :min="0"
  45. style="width: 80px"
  46. />
  47. </template>
  48. </el-table-column>
  49. <el-table-column
  50. prop="zip"
  51. label="操作"
  52. width="100"
  53. fixed="right"
  54. align="center"
  55. >
  56. <template #default="{ $index }">
  57. <el-button type="primary" link @click="list.splice($index,1)">
  58. 删除
  59. </el-button>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <template #footer>
  64. <el-button @click="visible = false" size="large">取 消</el-button>
  65. <el-button
  66. type="primary"
  67. @click="submitForm()"
  68. size="large"
  69. :loading="submitLoading"
  70. >
  71. 确 定
  72. </el-button>
  73. </template>
  74. </el-dialog>
  75. <el-dialog
  76. v-model="productVisible"
  77. title="选择产品"
  78. width="70%"
  79. append-to-body
  80. >
  81. <byTable
  82. :hideSearch="true"
  83. :source="productSource"
  84. :pagination="productPagination"
  85. :config="productConfig"
  86. :loading="productLoading"
  87. @get-list="getProductSource"
  88. highlight-current-row
  89. :selectConfig="[]"
  90. :table-events="{}"
  91. :action-list="[]"
  92. >
  93. </byTable>
  94. <template #footer>
  95. <span class="dialog-footer">
  96. <el-button @click="productVisible = false">取消</el-button>
  97. </span>
  98. </template>
  99. </el-dialog>
  100. </div>
  101. </template>
  102. <script setup>
  103. import byTable from "@/components/byTable/index";
  104. import {computed, getCurrentInstance, ref} from "vue";
  105. import {ElMessage} from "element-plus";
  106. const {proxy} = getCurrentInstance();
  107. const emits = defineEmits(['submit'])
  108. const submitLoading = ref(false);
  109. const list = ref([])
  110. const visible = ref(false)
  111. const loading = ref(false)
  112. const productVisible = ref(false)
  113. const productLoading = ref(false)
  114. const productSource = ref([])
  115. const productPagination = ref({
  116. total: 0,
  117. pageNum: 1,
  118. pageSize: 10,
  119. })
  120. const productConfig = computed(() => {
  121. return [
  122. {
  123. attrs: {
  124. label: "物品编码",
  125. prop: "productCustomCode",
  126. },
  127. },
  128. {
  129. attrs: {
  130. label: "物品名称",
  131. prop: "productName",
  132. },
  133. },
  134. {
  135. attrs: {
  136. label: "规格",
  137. prop: "productSpec",
  138. },
  139. },
  140. {
  141. attrs: {
  142. label: "单位",
  143. prop: "productUnit",
  144. },
  145. },
  146. {
  147. attrs: {
  148. label: "待质检数量",
  149. prop: "quantity",
  150. },
  151. },
  152. {
  153. attrs: {
  154. label: "操作",
  155. },
  156. renderHTML(row) {
  157. if (!list.value.map(item => item.productCustomCode).includes(row.productCustomCode)) {
  158. return [
  159. {
  160. attrs: {
  161. label: "选择",
  162. type: "primary",
  163. text: true,
  164. },
  165. el: "button",
  166. click() {
  167. list.value.push({
  168. ...row,
  169. qualifiedCount: row.quantity,
  170. defectiveCount: 0,
  171. scrappedCount: 0
  172. })
  173. },
  174. },
  175. ]
  176. } else {
  177. return []
  178. }
  179. },
  180. },
  181. ];
  182. });
  183. const open = () => {
  184. visible.value = true
  185. }
  186. const handleOpen = () => {
  187. productVisible.value = true
  188. getProductSource()
  189. }
  190. const getProductSource = (req) => {
  191. productPagination.value = {...productPagination.value, ...req}
  192. productLoading.value = true
  193. proxy.post("/jdRefundNotQualityCheck/page", productPagination.value)
  194. .then((data) => {
  195. productSource.value = data.rows;
  196. productPagination.value.total = data.total;
  197. })
  198. .finally(_ => {
  199. productLoading.value = false;
  200. })
  201. }
  202. const submitForm = () => {
  203. for (let item of list.value) {
  204. item.qualifiedCount = item.qualifiedCount ?? 0
  205. item.defectiveCount = item.defectiveCount ?? 0
  206. item.scrappedCount = item.scrappedCount ?? 0
  207. if (item.qualifiedCount + item.defectiveCount + item.scrappedCount > item.quantity) {
  208. ElMessage.error(`物品【${item.productCustomCode}】 良品数量+次品数量+报废数量 大于 质检数量`)
  209. return
  210. }
  211. }
  212. loading.value = true
  213. proxy.post("/jdRefundNotQualityCheck/submitQualityCheck", list.value)
  214. .then(() => {
  215. emits('submit')
  216. ElMessage.success(`质检成功`)
  217. visible.value = false
  218. list.value = []
  219. })
  220. .finally(_ => {
  221. loading.value = false;
  222. })
  223. }
  224. defineExpose({open})
  225. </script>