index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :searchConfig="searchConfig"
  10. highlight-current-row
  11. :action-list="[
  12. {
  13. text: '添加快递',
  14. action: () => clickModal(),
  15. },
  16. ]"
  17. @get-list="getList"
  18. @clickReset="clickReset">
  19. <template #address="{ item }">
  20. <div>{{ item.province }},{{ item.city }},{{ item.district }},{{ item.address }}</div>
  21. </template>
  22. </byTable>
  23. </el-card>
  24. <el-dialog :title="modalType == 'add' ? '添加快递' : '编辑快递'" v-if="openDialog" v-model="openDialog" width="60%">
  25. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit"> </byForm>
  26. <template #footer>
  27. <el-button @click="openDialog = false" size="large">取 消</el-button>
  28. <el-button type="primary" @click="submitForm()" size="large" v-preReClick>确 定</el-button>
  29. </template>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script setup>
  34. import byTable from "/src/components/byTable/index";
  35. import byForm from "/src/components/byForm/index";
  36. import { ElMessage, ElMessageBox } from "element-plus";
  37. import { ref } from "vue";
  38. const { proxy } = getCurrentInstance();
  39. const sourceList = ref({
  40. data: [],
  41. pagination: {
  42. total: 0,
  43. pageNum: 1,
  44. pageSize: 10,
  45. expressageCode: "",
  46. },
  47. });
  48. const loading = ref(false);
  49. const searchConfig = computed(() => {
  50. return [
  51. {
  52. type: "input",
  53. prop: "expressageCode",
  54. label: "快递编码",
  55. },
  56. ];
  57. });
  58. const config = computed(() => {
  59. return [
  60. {
  61. attrs: {
  62. label: "快递名称",
  63. prop: "expressage",
  64. width: 160,
  65. },
  66. },
  67. {
  68. attrs: {
  69. label: "打印机",
  70. prop: "printer",
  71. width: 140,
  72. },
  73. },
  74. {
  75. attrs: {
  76. label: "快递网点",
  77. prop: "branch",
  78. width: 140,
  79. },
  80. },
  81. {
  82. attrs: {
  83. label: "网点编码",
  84. prop: "branchCode",
  85. width: 140,
  86. },
  87. },
  88. {
  89. attrs: {
  90. label: "快递编码",
  91. prop: "expressageCode",
  92. width: 140,
  93. },
  94. },
  95. {
  96. attrs: {
  97. label: "联系人",
  98. prop: "name",
  99. width: 120,
  100. },
  101. },
  102. {
  103. attrs: {
  104. label: "电话",
  105. prop: "phone",
  106. width: 140,
  107. },
  108. },
  109. {
  110. attrs: {
  111. label: "发货地址",
  112. slot: "address",
  113. "min-width": 240,
  114. },
  115. },
  116. {
  117. attrs: {
  118. label: "取号模式",
  119. prop: "takeNum",
  120. width: 120,
  121. },
  122. render(val) {
  123. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["take_num"]);
  124. },
  125. },
  126. {
  127. attrs: {
  128. label: "操作",
  129. width: 80,
  130. align: "center",
  131. fixed: "right",
  132. },
  133. renderHTML(row) {
  134. return [
  135. {
  136. attrs: {
  137. label: "编辑",
  138. type: "primary",
  139. text: true,
  140. },
  141. el: "button",
  142. click() {
  143. clickUpdate(row);
  144. },
  145. },
  146. ];
  147. },
  148. },
  149. ];
  150. });
  151. const getList = async (req, status) => {
  152. if (status) {
  153. sourceList.value.pagination = {
  154. pageNum: sourceList.value.pagination.pageNum,
  155. pageSize: sourceList.value.pagination.pageSize,
  156. };
  157. } else {
  158. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  159. }
  160. loading.value = true;
  161. proxy.post("/expressDelivery/page", sourceList.value.pagination).then((res) => {
  162. sourceList.value.data = res.rows;
  163. sourceList.value.pagination.total = res.total;
  164. setTimeout(() => {
  165. loading.value = false;
  166. }, 200);
  167. });
  168. };
  169. getList();
  170. const clickReset = () => {
  171. getList("", true);
  172. };
  173. const modalType = ref("add");
  174. const openDialog = ref(false);
  175. const submit = ref(null);
  176. const formOption = reactive({
  177. inline: true,
  178. labelWidth: "140px",
  179. itemWidth: 100,
  180. rules: [],
  181. labelPosition: "right",
  182. });
  183. const formData = reactive({
  184. data: {},
  185. });
  186. const formConfig = computed(() => {
  187. return [
  188. {
  189. type: "input",
  190. prop: "name",
  191. label: "联系人",
  192. itemType: "text",
  193. },
  194. {
  195. type: "input",
  196. prop: "name",
  197. label: "电话",
  198. itemType: "text",
  199. },
  200. {
  201. type: "input",
  202. prop: "province",
  203. label: "省",
  204. itemType: "text",
  205. },
  206. {
  207. type: "input",
  208. prop: "city",
  209. label: "市",
  210. itemType: "text",
  211. },
  212. {
  213. type: "input",
  214. prop: "district",
  215. label: "区",
  216. itemType: "text",
  217. },
  218. {
  219. type: "input",
  220. prop: "address",
  221. label: "详细地址",
  222. itemType: "text",
  223. },
  224. {
  225. type: "input",
  226. prop: "expressage",
  227. label: "快递物流",
  228. itemType: "text",
  229. },
  230. {
  231. type: "input",
  232. prop: "expressageCode",
  233. label: "快递编码",
  234. itemType: "text",
  235. },
  236. {
  237. type: "input",
  238. prop: "branch",
  239. label: "快递网点",
  240. itemType: "text",
  241. },
  242. {
  243. type: "input",
  244. prop: "branchCode",
  245. label: "网点编码",
  246. itemType: "text",
  247. },
  248. {
  249. type: "input",
  250. prop: "templateUrl",
  251. label: "标准面单模板URL",
  252. itemType: "text",
  253. },
  254. {
  255. type: "input",
  256. prop: "customTemplateUrl",
  257. label: "自定义面单模板URL",
  258. itemType: "text",
  259. },
  260. {
  261. type: "select",
  262. prop: "takeNum",
  263. label: "取号模式",
  264. data: proxy.useUserStore().allDict["take_num"],
  265. },
  266. {
  267. type: "input",
  268. prop: "printer",
  269. label: "绑定打印机",
  270. itemType: "text",
  271. },
  272. ];
  273. });
  274. const rules = ref({
  275. name: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  276. phone: [{ required: true, message: "请输入电话", trigger: "blur" }],
  277. takeNum: [{ required: true, message: "请选择取号模式", trigger: "change" }],
  278. });
  279. const clickModal = () => {
  280. modalType.value = "add";
  281. formData.data = {};
  282. openDialog.value = true;
  283. };
  284. const submitForm = () => {
  285. submit.value.handleSubmit(() => {
  286. proxy.post("/expressDelivery/" + modalType.value, formData.data).then(() => {
  287. ElMessage({
  288. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  289. type: "success",
  290. });
  291. openDialog.value = false;
  292. getList();
  293. });
  294. });
  295. };
  296. const clickUpdate = (row) => {
  297. modalType.value = "edit";
  298. proxy.post("/expressDelivery/detail", { id: row.id }).then((res) => {
  299. formData.data = res;
  300. openDialog.value = true;
  301. });
  302. };
  303. </script>
  304. <style lang="scss" scoped>
  305. ::v-deep(.el-input-number .el-input__inner) {
  306. text-align: left;
  307. }
  308. </style>