index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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. @get-list="getList"
  18. >
  19. <template #code="{ item }">
  20. <div
  21. style="cursor: pointer; color: #409eff"
  22. @click="handleClickCode(item)"
  23. >
  24. {{ item.code }}
  25. </div>
  26. </template>
  27. <template #address="{ item }">
  28. <div>
  29. {{ item.countryName }}, {{ item.provinceName }} ,
  30. {{ item.cityName }}
  31. </div>
  32. </template>
  33. </byTable>
  34. </div>
  35. <el-dialog
  36. :title="modalType == 'add' ? '京东订单接收' : '调仓接收'"
  37. v-model="dialogVisible"
  38. width="800"
  39. v-loading="loading"
  40. >
  41. <byForm
  42. :formConfig="formConfig"
  43. :formOption="formOption"
  44. v-model="formData.data"
  45. :rules="rules"
  46. ref="byform"
  47. >
  48. <template #distributionCenter>
  49. <div>
  50. <el-autocomplete
  51. v-model="formData.data.distributionCenter"
  52. :fetch-suggestions="querySearchPerson"
  53. clearable
  54. class="inline-input w-50"
  55. placeholder="请输入"
  56. :disabled="true"
  57. >
  58. </el-autocomplete>
  59. </div>
  60. </template>
  61. <template #address>
  62. <el-row style="width: 100%">
  63. <el-col :span="8">
  64. <el-form-item prop="countryId">
  65. <el-select
  66. v-model="formData.data.countryId"
  67. placeholder="国家"
  68. @change="(val) => getCityData(val, '20', true)"
  69. :disabled="true"
  70. >
  71. <el-option
  72. v-for="item in countryData"
  73. :label="item.chineseName"
  74. :value="item.id"
  75. >
  76. </el-option>
  77. </el-select>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="8">
  81. <el-form-item prop="provinceId">
  82. <el-select
  83. v-model="formData.data.provinceId"
  84. placeholder="省/洲"
  85. @change="(val) => getCityData(val, '30', true)"
  86. :disabled="true"
  87. >
  88. <el-option
  89. v-for="item in provinceData"
  90. :label="item.name"
  91. :value="item.id"
  92. >
  93. </el-option>
  94. </el-select>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="8">
  98. <el-form-item prop="cityId">
  99. <el-select
  100. v-model="formData.data.cityId"
  101. placeholder="城市"
  102. :disabled="true"
  103. >
  104. <el-option
  105. v-for="item in cityData"
  106. :label="item.name"
  107. :value="item.id"
  108. >
  109. </el-option>
  110. </el-select>
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. <el-row style="margin-top: 20px; width: 100%">
  115. <el-col :span="24">
  116. <el-form-item prop="detailedAddress">
  117. <el-input
  118. v-model="formData.data.detailedAddress"
  119. type="textarea"
  120. :disabled="true"
  121. >
  122. </el-input>
  123. </el-form-item>
  124. </el-col>
  125. </el-row>
  126. </template>
  127. <template #products>
  128. <div style="width: 100%">
  129. <el-table :data="formData.data.jdOrderDetailsList">
  130. <el-table-column prop="productCode" label="物品编码" />
  131. <el-table-column prop="productName" label="物品名称" />
  132. <el-table-column prop="productName" label="规格型号" />
  133. <el-table-column prop="productName" label="调仓数量" />
  134. <el-table-column prop="quantity" label="接收数量" min-width="150">
  135. <template #default="{ row, $index }">
  136. <el-form-item
  137. :prop="'jdOrderDetailsList.' + $index + '.quantity'"
  138. :rules="rules.quantity"
  139. :inline-message="true"
  140. >
  141. <el-input-number
  142. v-model="row.quantity"
  143. :precision="4"
  144. :controls="false"
  145. :min="0"
  146. />
  147. </el-form-item>
  148. </template>
  149. </el-table-column>
  150. </el-table>
  151. </div>
  152. </template>
  153. </byForm>
  154. <template #footer>
  155. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  156. <el-button
  157. type="primary"
  158. @click="submitForm('byform')"
  159. size="large"
  160. :loading="submitLoading"
  161. >
  162. 确 定
  163. </el-button>
  164. </template>
  165. </el-dialog>
  166. <el-dialog
  167. v-model="openDetails"
  168. title="订单详情"
  169. width="40%"
  170. append-to-body
  171. >
  172. <OrderDetails
  173. :orderData="formData.orderData"
  174. :key="formData.orderData.id"
  175. ></OrderDetails>
  176. <template #footer>
  177. <span class="dialog-footer">
  178. <el-button @click="openDetails = false">取消</el-button>
  179. </span>
  180. </template>
  181. </el-dialog>
  182. </div>
  183. </template>
  184. <script setup>
  185. /* eslint-disable vue/no-unused-components */
  186. import { ElMessage, ElMessageBox } from "element-plus";
  187. import byTable from "@/components/byTable/index";
  188. import byForm from "@/components/byForm/index";
  189. import OrderDetails from "@/components/WDLY/order/details";
  190. const loading = ref(false);
  191. const submitLoading = ref(false);
  192. const sourceList = ref({
  193. data: [],
  194. pagination: {
  195. total: 3,
  196. pageNum: 1,
  197. pageSize: 10,
  198. },
  199. });
  200. let dialogVisible = ref(false);
  201. let openDetails = ref(false);
  202. let modalType = ref("add");
  203. let rules = ref({
  204. customerId: [
  205. {
  206. required: true,
  207. message: "请选择客户",
  208. trigger: "change",
  209. },
  210. ],
  211. type: [
  212. {
  213. required: true,
  214. message: "请选择订单类型",
  215. trigger: "change",
  216. },
  217. ],
  218. countryId: [
  219. {
  220. required: true,
  221. message: "请选择国家",
  222. trigger: "change",
  223. },
  224. ],
  225. provinceId: [
  226. {
  227. required: true,
  228. message: "请选择省/洲",
  229. trigger: "change",
  230. },
  231. ],
  232. cityId: [
  233. {
  234. required: true,
  235. message: "请选择城市",
  236. trigger: "change",
  237. },
  238. ],
  239. code: [
  240. {
  241. required: true,
  242. message: "请输入订单编号",
  243. trigger: "blur",
  244. },
  245. ],
  246. contactPerson: [
  247. {
  248. required: true,
  249. message: "请输入收货负责人",
  250. trigger: "blur",
  251. },
  252. ],
  253. contactNumber: [
  254. {
  255. required: true,
  256. message: "请输入收货电话",
  257. trigger: "blur",
  258. },
  259. ],
  260. detailedAddress: [
  261. {
  262. required: true,
  263. message: "请输入详细地址",
  264. trigger: "blur",
  265. },
  266. ],
  267. price: [
  268. {
  269. required: true,
  270. message: "请输入单价",
  271. trigger: "blur",
  272. },
  273. ],
  274. quantity: [
  275. {
  276. required: true,
  277. message: "请输入数量",
  278. trigger: "blur",
  279. },
  280. ],
  281. distributionCenter: [
  282. {
  283. required: true,
  284. message: "请输入/选择配送中心",
  285. trigger: "blur",
  286. },
  287. ],
  288. });
  289. const { proxy } = getCurrentInstance();
  290. const selectConfig = reactive([
  291. {
  292. label: "接收状态",
  293. prop: "status",
  294. data: [
  295. {
  296. label: "未出库",
  297. value: "1",
  298. },
  299. {
  300. label: "部分出库",
  301. value: "2",
  302. },
  303. {
  304. label: "已出库",
  305. value: "3",
  306. },
  307. ],
  308. },
  309. ]);
  310. const config = computed(() => {
  311. return [
  312. {
  313. attrs: {
  314. label: "订单编号",
  315. prop: "code",
  316. slot: "code",
  317. },
  318. },
  319. {
  320. attrs: {
  321. label: "配送中心",
  322. prop: "distributionCenter",
  323. },
  324. },
  325. {
  326. attrs: {
  327. label: "所在城市",
  328. prop: "address",
  329. slot: "address",
  330. width: "150",
  331. },
  332. },
  333. {
  334. attrs: {
  335. label: "详细地址",
  336. prop: "detailedAddress",
  337. width: "300",
  338. },
  339. },
  340. {
  341. attrs: {
  342. label: "收货负责人",
  343. prop: "contactPerson",
  344. },
  345. },
  346. {
  347. attrs: {
  348. label: "收货电话",
  349. prop: "contactNumber",
  350. width: "180",
  351. },
  352. },
  353. {
  354. attrs: {
  355. label: "接收人",
  356. prop: "status",
  357. },
  358. },
  359. {
  360. attrs: {
  361. label: "接收时间",
  362. prop: "status",
  363. },
  364. },
  365. {
  366. attrs: {
  367. label: "接收状态",
  368. prop: "status",
  369. },
  370. },
  371. {
  372. attrs: {
  373. label: "操作",
  374. width: "100",
  375. align: "right",
  376. },
  377. // 渲染 el-button,一般用在最后一列。
  378. renderHTML(row) {
  379. return [
  380. {
  381. attrs: {
  382. label: "接收",
  383. type: "primary",
  384. text: true,
  385. },
  386. el: "button",
  387. click() {
  388. openModal();
  389. },
  390. },
  391. ];
  392. },
  393. },
  394. ];
  395. });
  396. let formData = reactive({
  397. data: {},
  398. treeData: [],
  399. orderData: {},
  400. });
  401. const formOption = reactive({
  402. disabled: false,
  403. inline: true,
  404. labelWidth: 100,
  405. itemWidth: 100,
  406. rules: [],
  407. });
  408. const byform = ref(null);
  409. const treeData = ref([]);
  410. const formConfig = reactive([
  411. {
  412. type: "title",
  413. title: "订单信息",
  414. },
  415. {
  416. type: "select",
  417. prop: "customerId",
  418. label: "客户名称",
  419. isLoad: {
  420. url: "/customer/page",
  421. req: {
  422. pageNum: 1,
  423. pageSize: 9999,
  424. },
  425. labelKey: "name",
  426. labelVal: "id",
  427. method: "post",
  428. resUrl: "rows",
  429. },
  430. itemWidth: 30,
  431. disabled: true,
  432. },
  433. {
  434. type: "input",
  435. prop: "code",
  436. label: "订单编号",
  437. itemWidth: 20,
  438. disabled: true,
  439. },
  440. {
  441. type: "slot",
  442. prop: "distributionCenter",
  443. label: "配送中心",
  444. slotName: "distributionCenter",
  445. disabled: true,
  446. },
  447. {
  448. type: "input",
  449. prop: "contactPerson",
  450. label: "收货信息",
  451. itemWidth: 20,
  452. placeholder: "收货负责人",
  453. disabled: true,
  454. },
  455. {
  456. type: "input",
  457. prop: "contactNumber",
  458. label: " ",
  459. itemWidth: 30,
  460. placeholder: "收货电话",
  461. disabled: true,
  462. },
  463. {
  464. type: "slot",
  465. slotName: "address",
  466. prop: "countryId",
  467. label: "详细地址",
  468. required: true,
  469. disabled: true,
  470. },
  471. {
  472. type: "title",
  473. title: "调仓明细",
  474. },
  475. {
  476. type: "slot",
  477. slotName: "products",
  478. },
  479. ]);
  480. const getList = async (req) => {
  481. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  482. loading.value = true;
  483. proxy
  484. .post("/jdOrder/receivePage", sourceList.value.pagination)
  485. .then((message) => {
  486. console.log(message);
  487. sourceList.value.data = message.rows;
  488. sourceList.value.pagination.total = message.total;
  489. setTimeout(() => {
  490. loading.value = false;
  491. }, 200);
  492. });
  493. };
  494. const openModal = () => {
  495. dialogVisible.value = true;
  496. modalType.value = "add";
  497. formData.data = {
  498. jdOrderDetailsList: [{}],
  499. countryId: "China",
  500. };
  501. getCityData(formData.data.countryId, "20");
  502. };
  503. const submitForm = () => {
  504. console.log(byform.value);
  505. byform.value.handleSubmit((valid) => {
  506. const list = formData.data.jdOrderDetailsList;
  507. if (!list.length > 0)
  508. return ElMessage({
  509. message: `请添加订单明细!`,
  510. type: "info",
  511. });
  512. for (let i = 0; i < list.length; i++) {
  513. const e = list[i];
  514. if (e.quantity == 0) {
  515. return ElMessage({
  516. message: `数量不能为0!`,
  517. type: "info",
  518. });
  519. }
  520. }
  521. submitLoading.value = true;
  522. proxy.post("/jdOrder/" + modalType.value, formData.data).then(
  523. (res) => {
  524. ElMessage({
  525. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  526. type: "success",
  527. });
  528. dialogVisible.value = false;
  529. submitLoading.value = false;
  530. getList();
  531. },
  532. (err) => (submitLoading.value = false)
  533. );
  534. });
  535. };
  536. const warehouseList = ref([]);
  537. const salesType = ref([]);
  538. const getDict = () => {
  539. proxy.getDict(["order_sales_type"]).then((res) => {
  540. salesType.value = res["order_sales_type"];
  541. formConfig[1].data = salesType.value.map((x) => ({
  542. label: x.dictValue,
  543. value: x.dictKey,
  544. }));
  545. });
  546. };
  547. const countryData = ref([]);
  548. const provinceData = ref([]);
  549. const cityData = ref([]);
  550. const getCityData = (id, type, isChange) => {
  551. proxy.post("/areaInfo/list", { parentId: id }).then((res) => {
  552. if (type === "20") {
  553. provinceData.value = res;
  554. if (isChange) {
  555. formData.data.provinceId = "";
  556. formData.data.cityId = "";
  557. }
  558. } else if (type === "30") {
  559. cityData.value = res;
  560. if (isChange) {
  561. formData.data.cityId = "";
  562. }
  563. } else {
  564. countryData.value = res;
  565. }
  566. });
  567. };
  568. getCityData("0");
  569. getList();
  570. // getDict();
  571. const handleClickCode = (row) => {
  572. // formData.orderData = row;
  573. // openDetails.value = true;
  574. };
  575. </script>
  576. <style lang="scss" scoped>
  577. .tenant {
  578. padding: 20px;
  579. }
  580. </style>