123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- <template>
- <div>
- <el-card class="box-card">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- :searchConfig="searchConfig"
- highlight-current-row
- :action-list="[
- {
- text: '添加快递',
- action: () => clickModal(),
- },
- ]"
- @get-list="getList"
- @clickReset="clickReset">
- <template #address="{ item }">
- <div>{{ item.province }},{{ item.city }},{{ item.district }},{{ item.address }}</div>
- </template>
- </byTable>
- </el-card>
- <el-dialog :title="modalType == 'add' ? '添加快递' : '编辑快递'" v-if="openDialog" v-model="openDialog" width="60%">
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit"> </byForm>
- <template #footer>
- <el-button @click="openDialog = false" size="large">取 消</el-button>
- <el-button type="primary" @click="submitForm()" size="large" v-preReClick>确 定</el-button>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import byTable from "/src/components/byTable/index";
- import byForm from "/src/components/byForm/index";
- import { ElMessage, ElMessageBox } from "element-plus";
- import { ref } from "vue";
- const { proxy } = getCurrentInstance();
- const sourceList = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- expressageCode: "",
- },
- });
- const loading = ref(false);
- const searchConfig = computed(() => {
- return [
- {
- type: "input",
- prop: "expressageCode",
- label: "快递编码",
- },
- ];
- });
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "快递名称",
- prop: "expressage",
- width: 160,
- },
- },
- {
- attrs: {
- label: "打印机",
- prop: "printer",
- width: 140,
- },
- },
- {
- attrs: {
- label: "快递网点",
- prop: "branch",
- width: 140,
- },
- },
- {
- attrs: {
- label: "网点编码",
- prop: "branchCode",
- width: 140,
- },
- },
- {
- attrs: {
- label: "快递编码",
- prop: "expressageCode",
- width: 140,
- },
- },
- {
- attrs: {
- label: "联系人",
- prop: "name",
- width: 120,
- },
- },
- {
- attrs: {
- label: "电话",
- prop: "phone",
- width: 140,
- },
- },
- {
- attrs: {
- label: "发货地址",
- slot: "address",
- "min-width": 240,
- },
- },
- {
- attrs: {
- label: "取号模式",
- prop: "takeNum",
- width: 120,
- },
- render(val) {
- return proxy.dictKeyValue(val, proxy.useUserStore().allDict["take_num"]);
- },
- },
- {
- attrs: {
- label: "操作",
- width: 80,
- align: "center",
- fixed: "right",
- },
- renderHTML(row) {
- return [
- {
- attrs: {
- label: "编辑",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- clickUpdate(row);
- },
- },
- ];
- },
- },
- ];
- });
- const getList = async (req, status) => {
- if (status) {
- sourceList.value.pagination = {
- pageNum: sourceList.value.pagination.pageNum,
- pageSize: sourceList.value.pagination.pageSize,
- };
- } else {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- }
- loading.value = true;
- proxy.post("/expressDelivery/page", sourceList.value.pagination).then((res) => {
- sourceList.value.data = res.rows;
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- getList();
- const clickReset = () => {
- getList("", true);
- };
- const modalType = ref("add");
- const openDialog = ref(false);
- const submit = ref(null);
- const formOption = reactive({
- inline: true,
- labelWidth: "140px",
- itemWidth: 100,
- rules: [],
- labelPosition: "right",
- });
- const formData = reactive({
- data: {},
- });
- const formConfig = computed(() => {
- return [
- {
- type: "input",
- prop: "name",
- label: "联系人",
- itemType: "text",
- },
- {
- type: "input",
- prop: "name",
- label: "电话",
- itemType: "text",
- },
- {
- type: "input",
- prop: "province",
- label: "省",
- itemType: "text",
- },
- {
- type: "input",
- prop: "city",
- label: "市",
- itemType: "text",
- },
- {
- type: "input",
- prop: "district",
- label: "区",
- itemType: "text",
- },
- {
- type: "input",
- prop: "address",
- label: "详细地址",
- itemType: "text",
- },
- {
- type: "input",
- prop: "expressage",
- label: "快递物流",
- itemType: "text",
- },
- {
- type: "input",
- prop: "expressageCode",
- label: "快递编码",
- itemType: "text",
- },
- {
- type: "input",
- prop: "branch",
- label: "快递网点",
- itemType: "text",
- },
- {
- type: "input",
- prop: "branchCode",
- label: "网点编码",
- itemType: "text",
- },
- {
- type: "input",
- prop: "templateUrl",
- label: "标准面单模板URL",
- itemType: "text",
- },
- {
- type: "input",
- prop: "customTemplateUrl",
- label: "自定义面单模板URL",
- itemType: "text",
- },
- {
- type: "select",
- prop: "takeNum",
- label: "取号模式",
- data: proxy.useUserStore().allDict["take_num"],
- },
- {
- type: "input",
- prop: "printer",
- label: "绑定打印机",
- itemType: "text",
- },
- ];
- });
- const rules = ref({
- name: [{ required: true, message: "请输入联系人", trigger: "blur" }],
- phone: [{ required: true, message: "请输入电话", trigger: "blur" }],
- takeNum: [{ required: true, message: "请选择取号模式", trigger: "change" }],
- });
- const clickModal = () => {
- modalType.value = "add";
- formData.data = {};
- openDialog.value = true;
- };
- const submitForm = () => {
- submit.value.handleSubmit(() => {
- proxy.post("/expressDelivery/" + modalType.value, formData.data).then(() => {
- ElMessage({
- message: modalType.value == "add" ? "添加成功" : "编辑成功",
- type: "success",
- });
- openDialog.value = false;
- getList();
- });
- });
- };
- const clickUpdate = (row) => {
- modalType.value = "edit";
- proxy.post("/expressDelivery/detail", { id: row.id }).then((res) => {
- formData.data = res;
- openDialog.value = true;
- });
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep(.el-input-number .el-input__inner) {
- text-align: left;
- }
- </style>
|