index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :selectConfig="selectConfig"
  12. :table-events="{
  13. //element talbe事件都能传
  14. select: select,
  15. }"
  16. :action-list="[
  17. {
  18. text: '新增调仓',
  19. action: () => openModal('add'),
  20. },
  21. ]"
  22. @get-list="getList"
  23. >
  24. <template #slotName="{ item }">
  25. {{ item.createTime }}
  26. </template>
  27. </byTable>
  28. </div>
  29. <el-dialog
  30. :title="modalType == 'add' ? '新增调仓' : '调仓接收'"
  31. v-model="dialogVisible"
  32. width="800"
  33. v-loading="loading"
  34. >
  35. <byForm
  36. :formConfig="formConfig"
  37. :formOption="formOption"
  38. v-model="formData.data"
  39. :rules="rules"
  40. ref="byform"
  41. >
  42. <template #products>
  43. <div style="width: 100%">
  44. <el-button
  45. type="primary"
  46. @click="openProduct = true"
  47. style="margin-bottom: 10px"
  48. >
  49. 添加物品
  50. </el-button>
  51. <el-table :data="formData.data.stockWaitDetailsList">
  52. <el-table-column prop="name" label="物品编码" />
  53. <el-table-column prop="name" label="物品名称" />
  54. <el-table-column prop="name" label="规格型号" />
  55. <el-table-column
  56. prop="name"
  57. label="调仓数量"
  58. v-if="modalType == 'edit'"
  59. />
  60. <el-table-column
  61. prop="quantity"
  62. label="调仓数量"
  63. min-width="150"
  64. v-if="modalType == 'add'"
  65. >
  66. <template #default="{ row, $index }">
  67. <el-form-item
  68. :prop="'stockWaitDetailsList.' + $index + '.quantity'"
  69. :rules="rules.quantity"
  70. :inline-message="true"
  71. >
  72. <el-input-number
  73. v-model="row.quantity"
  74. :precision="4"
  75. :controls="false"
  76. :min="0"
  77. />
  78. </el-form-item>
  79. </template>
  80. </el-table-column>
  81. <el-table-column
  82. prop="quantity"
  83. label="接收数量"
  84. min-width="150"
  85. v-if="modalType == 'edit'"
  86. >
  87. <template #default="{ row, $index }">
  88. <el-form-item
  89. :prop="'stockWaitDetailsList.' + $index + '.quantity'"
  90. :rules="rules.quantity"
  91. :inline-message="true"
  92. >
  93. <el-input-number
  94. v-model="row.quantity"
  95. :precision="4"
  96. :controls="false"
  97. :min="0"
  98. />
  99. </el-form-item>
  100. </template>
  101. </el-table-column>
  102. <el-table-column prop="zip" label="操作" width="100">
  103. <template #default="{ $index }">
  104. <el-button type="primary" link @click="handleRemove($index)"
  105. >删除</el-button
  106. >
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. </div>
  111. </template>
  112. </byForm>
  113. <template #footer>
  114. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  115. <el-button
  116. type="primary"
  117. @click="submitForm('byform')"
  118. size="large"
  119. :loading="submitLoading"
  120. >
  121. 确 定
  122. </el-button>
  123. </template>
  124. </el-dialog>
  125. <el-dialog
  126. v-model="openProduct"
  127. title="选择产品"
  128. width="70%"
  129. append-to-body
  130. >
  131. <SelectProduct @handleSelect="handleSelect"></SelectProduct>
  132. <template #footer>
  133. <span class="dialog-footer">
  134. <el-button @click="openProduct = false">取消</el-button>
  135. </span>
  136. </template>
  137. </el-dialog>
  138. </div>
  139. </template>
  140. <script setup>
  141. /* eslint-disable vue/no-unused-components */
  142. import { ElMessage, ElMessageBox } from "element-plus";
  143. import byTable from "@/components/byTable/index";
  144. import byForm from "@/components/byForm/index";
  145. import { computed, defineComponent, ref } from "vue";
  146. import useUserStore from "@/store/modules/user";
  147. import SelectProduct from "@/components/WDLY/product/SelectProduct";
  148. const loading = ref(false);
  149. const submitLoading = ref(false);
  150. const sourceList = ref({
  151. data: [],
  152. pagination: {
  153. total: 3,
  154. pageNum: 1,
  155. pageSize: 10,
  156. },
  157. });
  158. let dialogVisible = ref(false);
  159. let openProduct = ref(false);
  160. let roomDialogVisible = ref(false);
  161. let modalType = ref("add");
  162. let rules = ref({
  163. code: [{ required: true, message: "请输入spu编码", trigger: "blur" }],
  164. name: [{ required: true, message: "请输入spu名称", trigger: "blur" }],
  165. });
  166. const { proxy } = getCurrentInstance();
  167. const selectConfig = reactive([
  168. {
  169. label: "调出仓库",
  170. prop: "type",
  171. data: [],
  172. },
  173. {
  174. label: "调入仓库",
  175. prop: "type",
  176. data: [],
  177. },
  178. {
  179. label: "接收状态",
  180. prop: "type",
  181. data: [
  182. {
  183. label: "待接收",
  184. value: "1",
  185. },
  186. {
  187. label: "部分接收",
  188. value: "2",
  189. },
  190. {
  191. label: "已接收",
  192. value: "2",
  193. },
  194. ],
  195. },
  196. ]);
  197. const config = computed(() => {
  198. return [
  199. {
  200. attrs: {
  201. label: "单号",
  202. prop: "code",
  203. },
  204. },
  205. {
  206. attrs: {
  207. label: "调出仓库",
  208. prop: "name",
  209. },
  210. },
  211. {
  212. attrs: {
  213. label: "调出人",
  214. prop: "remark",
  215. },
  216. },
  217. {
  218. attrs: {
  219. label: "调出时间",
  220. prop: "remark",
  221. },
  222. },
  223. {
  224. attrs: {
  225. label: "接收状态",
  226. prop: "remark",
  227. },
  228. },
  229. {
  230. attrs: {
  231. label: "调入仓库",
  232. prop: "remark",
  233. },
  234. },
  235. {
  236. attrs: {
  237. label: "接收人",
  238. prop: "remark",
  239. },
  240. },
  241. {
  242. attrs: {
  243. label: "接收时间",
  244. prop: "remark",
  245. },
  246. },
  247. {
  248. attrs: {
  249. label: "操作",
  250. width: "200",
  251. align: "right",
  252. },
  253. // 渲染 el-button,一般用在最后一列。
  254. renderHTML(row) {
  255. return [
  256. {
  257. attrs: {
  258. label: "接收",
  259. type: "primary",
  260. text: true,
  261. },
  262. el: "button",
  263. click() {
  264. getDtl(row);
  265. },
  266. },
  267. {
  268. attrs: {
  269. label: "打印",
  270. type: "primary",
  271. text: true,
  272. },
  273. el: "button",
  274. click() {
  275. getDtl(row);
  276. },
  277. },
  278. ];
  279. },
  280. },
  281. ];
  282. });
  283. let formData = reactive({
  284. data: {},
  285. treeData: [],
  286. });
  287. const formOption = reactive({
  288. inline: true,
  289. labelWidth: 100,
  290. itemWidth: 100,
  291. rules: [],
  292. });
  293. const byform = ref(null);
  294. const treeData = ref([]);
  295. const formConfig = reactive([
  296. {
  297. type: "title",
  298. title: "调仓信息",
  299. },
  300. {
  301. type: "select",
  302. prop: "warehouseId",
  303. label: "调出仓库",
  304. itemWidth: 33,
  305. disabled: modalType.value === "edit",
  306. data: [],
  307. },
  308. {
  309. type: "select",
  310. prop: "warehouseId",
  311. label: "调入仓库",
  312. itemWidth: 33,
  313. disabled: modalType.value === "edit",
  314. data: [],
  315. },
  316. {
  317. type: "input",
  318. prop: "name",
  319. label: "调拨说明",
  320. itemType: "textarea",
  321. disabled: modalType.value === "edit",
  322. },
  323. {
  324. type: "title",
  325. title: "调仓明细",
  326. },
  327. {
  328. type: "slot",
  329. slotName: "products",
  330. },
  331. ]);
  332. const getList = async (req) => {
  333. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  334. loading.value = true;
  335. proxy
  336. .post("/productSpu/page", sourceList.value.pagination)
  337. .then((message) => {
  338. console.log(message);
  339. sourceList.value.data = message.rows;
  340. sourceList.value.pagination.total = message.total;
  341. setTimeout(() => {
  342. loading.value = false;
  343. }, 200);
  344. });
  345. };
  346. const openModal = () => {
  347. dialogVisible.value = true;
  348. modalType.value = "add";
  349. formData.data = {
  350. stockWaitDetailsList: [],
  351. };
  352. };
  353. const submitForm = () => {
  354. console.log(byform.value);
  355. byform.value.handleSubmit((valid) => {
  356. submitLoading.value = true;
  357. proxy.post("/productSpu/" + modalType.value, formData.data).then(
  358. (res) => {
  359. ElMessage({
  360. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  361. type: "success",
  362. });
  363. dialogVisible.value = false;
  364. submitLoading.value = false;
  365. getList();
  366. },
  367. (err) => (submitLoading.value = false)
  368. );
  369. });
  370. };
  371. const getDtl = (row) => {
  372. modalType.value = "edit";
  373. proxy.post("/productSpu/detail", { id: row.id }).then((res) => {
  374. res.stockWaitDetailsList = res.productInfoList;
  375. formData.data = res;
  376. dialogVisible.value = true;
  377. });
  378. };
  379. const warehouseList = ref([]);
  380. const warehouseListData = () => {
  381. // // 币种数据
  382. proxy
  383. .post("/warehouse/page", {
  384. pageNum: 1,
  385. pageSize: 10,
  386. })
  387. .then((message) => {
  388. warehouseList.value = message.rows;
  389. formConfig[1].data = message.rows.map((x) => ({
  390. label: x.name,
  391. value: x.id,
  392. }));
  393. formConfig[2].data = message.rows.map((x) => ({
  394. label: x.name,
  395. value: x.id,
  396. }));
  397. selectConfig[0].data = message.rows.map((x) => ({
  398. label: x.name,
  399. value: x.id,
  400. }));
  401. selectConfig[1].data = message.rows.map((x) => ({
  402. label: x.name,
  403. value: x.id,
  404. }));
  405. });
  406. };
  407. getList();
  408. warehouseListData();
  409. const handleSelect = (row) => {
  410. const flag = formData.data.stockWaitDetailsList.some((x) => x.id === row.id);
  411. if (flag)
  412. return ElMessage({
  413. message: "该物品已选择",
  414. type: "info",
  415. });
  416. formData.data.stockWaitDetailsList.push({
  417. name: row.name,
  418. code: row.code,
  419. id: row.id,
  420. });
  421. return ElMessage({
  422. message: "选择成功",
  423. type: "success",
  424. });
  425. };
  426. const handleRemove = (index) => {
  427. formData.data.stockWaitDetailsList.splice(index, 1);
  428. return ElMessage({
  429. message: "删除成功",
  430. type: "success",
  431. });
  432. };
  433. </script>
  434. <style lang="scss" scoped>
  435. .tenant {
  436. padding: 20px;
  437. }
  438. </style>