index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <div>
  3. <el-card :class="props.selectStatus ? 'select-card' : 'box-card'">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :searchConfig="searchConfig"
  10. :defaultExpandAll="props.selectStatus"
  11. highlight-current-row
  12. :action-list="[
  13. props.selectStatus
  14. ? {}
  15. : {
  16. text: '添加产品',
  17. action: () => clickModal(),
  18. },
  19. props.selectStatus
  20. ? {}
  21. : {
  22. text: '批量修改',
  23. action: () => batchModification(),
  24. },
  25. // {
  26. // text: '操作日志',
  27. // action: () => viewLogs(),
  28. // },
  29. ]"
  30. @get-list="getList"
  31. @clickReset="clickReset">
  32. <template #typeExpand="{ item }">
  33. <div style="padding: 0px 20px; box-sizing: border-box" v-if="item.skuSpecList && item.skuSpecList.length > 0">
  34. <div
  35. v-for="spec in item.skuSpecList"
  36. :key="spec.id"
  37. style="display: flex; padding: 8px 16px; align-items: center; box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1); margin-bottom: 8px">
  38. <div style="width: 80px">
  39. <div v-if="spec.specImgUrl">
  40. <img
  41. style="width: 40px; height: 40px; object-fit: contain; vertical-align: middle; border: none; cursor: pointer"
  42. :src="spec.specImgUrl"
  43. @click="openFile(spec.specImgUrl)" />
  44. </div>
  45. <div
  46. v-else
  47. class="el-icon-picture-outline"
  48. style="width: 40px; height: 40px; font-size: 36px; line-height: 40px; text-align: center; color: rgb(229 228 228)"></div>
  49. </div>
  50. <div style="width: 180px">
  51. {{ spec.code }}
  52. </div>
  53. <div style="flex: 1">
  54. {{ spec.name }}
  55. </div>
  56. <div style="width: 180px">
  57. {{ `${spec.length} * ${spec.width} * ${spec.height}(cm³)` }}
  58. </div>
  59. <div style="width: 60px; text-align: center" v-if="props.selectStatus">
  60. <el-button type="primary" text @click="selectProduct(spec, item)" v-preReClick>选择</el-button>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <template #name="{ item }">
  66. <div>
  67. <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="clickName(item)">{{ item.name }}</a>
  68. </div>
  69. </template>
  70. </byTable>
  71. </el-card>
  72. <el-dialog :title="modalTitle" v-if="openDialog" v-model="openDialog" width="90%">
  73. <MakeSKU :rowData="rowData" :detailStatus="detailStatus" @clickCancel="clickCancel"></MakeSKU>
  74. </el-dialog>
  75. <el-dialog title="操作日志" v-if="openLogs" v-model="openLogs" width="50%">
  76. <byTable
  77. :source="logsList.data"
  78. :pagination="logsList.pagination"
  79. :config="configLogs"
  80. :loading="loadingLogs"
  81. highlight-current-row
  82. @get-list="getLogsList">
  83. </byTable>
  84. <template #footer>
  85. <el-button @click="openLogs = false" size="large">关 闭</el-button>
  86. </template>
  87. </el-dialog>
  88. <el-dialog title="批量修改" v-if="openModification" v-model="openModification" width="96%">
  89. <Modification :type="0" @clickCancel="clickModificationCancel"></Modification>
  90. </el-dialog>
  91. </div>
  92. </template>
  93. <script setup>
  94. import byTable from "/src/components/byTable/index";
  95. import MakeSKU from "/src/components/makeProduct/index";
  96. import Modification from "/src/components/makeProduct/modification/index";
  97. const { proxy } = getCurrentInstance();
  98. const props = defineProps({
  99. selectStatus: Boolean,
  100. });
  101. const sourceList = ref({
  102. data: [],
  103. pagination: {
  104. total: 0,
  105. pageNum: 1,
  106. pageSize: 10,
  107. name: "",
  108. code: "",
  109. specCode: "",
  110. specName: "",
  111. type: 0,
  112. brand: "",
  113. },
  114. });
  115. const loading = ref(false);
  116. const searchConfig = computed(() => {
  117. return [
  118. {
  119. type: "input",
  120. prop: "code",
  121. label: "群组品号",
  122. },
  123. {
  124. type: "input",
  125. prop: "name",
  126. label: "群组品名",
  127. },
  128. {
  129. type: "input",
  130. prop: "specCode",
  131. label: "品号",
  132. },
  133. {
  134. type: "input",
  135. prop: "specName",
  136. label: "品名",
  137. },
  138. {
  139. type: "select",
  140. prop: "brand",
  141. dictKey: "wlnBrand",
  142. label: "品牌",
  143. },
  144. ];
  145. });
  146. const config = computed(() => {
  147. return [
  148. {
  149. type: "expand",
  150. attrs: {
  151. label: " ",
  152. slot: "typeExpand",
  153. width: 50,
  154. },
  155. },
  156. {
  157. attrs: {
  158. label: "群组品号",
  159. prop: "code",
  160. width: 180,
  161. },
  162. },
  163. {
  164. attrs: {
  165. label: "群组品名",
  166. slot: "name",
  167. "min-width": 240,
  168. },
  169. },
  170. {
  171. attrs: {
  172. label: "产品来源",
  173. prop: "source",
  174. width: 120,
  175. },
  176. render(val) {
  177. return val == 1 ? "MES" : "万里牛";
  178. },
  179. },
  180. {
  181. attrs: {
  182. label: "品牌",
  183. prop: "brand",
  184. width: 120,
  185. },
  186. render(val) {
  187. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["wlnBrand"]);
  188. },
  189. },
  190. {
  191. attrs: {
  192. label: "型号",
  193. prop: "modelNumber",
  194. width: 200,
  195. },
  196. },
  197. {
  198. attrs: {
  199. label: "材质",
  200. prop: "material",
  201. width: 200,
  202. },
  203. },
  204. props.selectStatus
  205. ? {
  206. attrs: { width: 1 },
  207. }
  208. : {
  209. attrs: {
  210. label: "操作",
  211. width: 80,
  212. align: "center",
  213. fixed: "right",
  214. },
  215. renderHTML(row) {
  216. return [
  217. {
  218. attrs: {
  219. label: "编辑",
  220. type: "primary",
  221. text: true,
  222. },
  223. el: "button",
  224. click() {
  225. clickUpdate(row);
  226. },
  227. },
  228. ];
  229. },
  230. },
  231. ];
  232. });
  233. const getList = async (req, status) => {
  234. if (status) {
  235. sourceList.value.pagination = {
  236. pageNum: sourceList.value.pagination.pageNum,
  237. pageSize: sourceList.value.pagination.pageSize,
  238. type: 0,
  239. };
  240. } else {
  241. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  242. }
  243. loading.value = true;
  244. proxy.post("/sku/page", sourceList.value.pagination).then((res) => {
  245. sourceList.value.data = res.rows;
  246. sourceList.value.pagination.total = res.total;
  247. setTimeout(() => {
  248. loading.value = false;
  249. }, 200);
  250. });
  251. };
  252. getList();
  253. const clickReset = () => {
  254. getList("", true);
  255. };
  256. const modalTitle = ref("添加SKU");
  257. const openDialog = ref(false);
  258. const rowData = ref({});
  259. const detailStatus = ref(false);
  260. const clickModal = () => {
  261. modalTitle.value = "添加SKU";
  262. rowData.value = {};
  263. detailStatus.value = false;
  264. openDialog.value = true;
  265. };
  266. const clickUpdate = (row) => {
  267. modalTitle.value = "编辑SKU";
  268. rowData.value = row;
  269. detailStatus.value = false;
  270. openDialog.value = true;
  271. };
  272. const clickCancel = (status) => {
  273. openDialog.value = false;
  274. if (status) {
  275. getList();
  276. }
  277. };
  278. const openFile = (path) => {
  279. window.open(path);
  280. };
  281. const clickName = (row) => {
  282. modalTitle.value = "SKU详情";
  283. rowData.value = row;
  284. detailStatus.value = true;
  285. openDialog.value = true;
  286. };
  287. const openLogs = ref(false);
  288. const loadingLogs = ref(false);
  289. const logsList = ref({
  290. data: [],
  291. pagination: {
  292. total: 0,
  293. pageNum: 1,
  294. pageSize: 10,
  295. },
  296. });
  297. const type = ref([
  298. { dictKey: "1", dictValue: "新增" },
  299. { dictKey: "2", dictValue: "修改" },
  300. { dictKey: "3", dictValue: "删除" },
  301. ]);
  302. const configLogs = computed(() => {
  303. return [
  304. {
  305. attrs: {
  306. label: "操作时间",
  307. prop: "createTime",
  308. width: 160,
  309. align: "center",
  310. },
  311. },
  312. {
  313. attrs: {
  314. label: "操作人",
  315. prop: "operator",
  316. align: "center",
  317. },
  318. },
  319. {
  320. attrs: {
  321. label: "SKU品号",
  322. prop: "code",
  323. align: "center",
  324. },
  325. },
  326. {
  327. attrs: {
  328. label: "行为",
  329. prop: "type",
  330. width: 100,
  331. align: "center",
  332. },
  333. render(val) {
  334. return proxy.dictKeyValue(val, type.value);
  335. },
  336. },
  337. ];
  338. });
  339. const viewLogs = () => {
  340. logsList.value.data = [];
  341. logsList.value.pagination.total = 0;
  342. openLogs.value = true;
  343. getLogsList({ pageNum: 1, pageSize: 10 });
  344. };
  345. const getLogsList = async (req) => {
  346. logsList.value.pagination = { ...logsList.value.pagination, ...req };
  347. loadingLogs.value = true;
  348. proxy.post("/bomOperatingLog/page", logsList.value.pagination).then((res) => {
  349. logsList.value.data = res.rows;
  350. logsList.value.pagination.total = res.total;
  351. setTimeout(() => {
  352. loadingLogs.value = false;
  353. }, 200);
  354. });
  355. };
  356. const emit = defineEmits(["selectProduct"]);
  357. const selectProduct = (spec, item) => {
  358. emit("selectProduct", spec, item);
  359. };
  360. const openModification = ref(false);
  361. const batchModification = () => {
  362. openModification.value = true;
  363. };
  364. const clickModificationCancel = (status) => {
  365. openModification.value = false;
  366. if (status) {
  367. getList();
  368. }
  369. };
  370. </script>
  371. <style lang="scss" scoped>
  372. :deep(.el-dialog) {
  373. margin-top: 10px !important;
  374. margin-bottom: 10px !important;
  375. }
  376. .select-card {
  377. height: calc(100vh - 184px);
  378. overflow-y: auto;
  379. overflow-x: hidden;
  380. }
  381. </style>