lxf 1 год назад
Родитель
Сommit
7746f75d3a

+ 2 - 1
src/components/byForm/index.vue

@@ -131,7 +131,8 @@
           :precision="i.precision !== '' ? i.precision : 2"
           :controls="i.controls === false ? false : true"
           :style="i.style"
-          onmousewheel="return false;">
+          onmousewheel="return false;"
+          style="width: 100%">
         </el-input-number>
         <el-tree
           v-else-if="i.type == 'tree'"

+ 431 - 0
src/views/group/subsidiary/business-division/index.vue

@@ -0,0 +1,431 @@
+<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">
+      </byTable>
+    </el-card>
+
+    <el-dialog :title="modalType == 'add' ? '添加事业部' : '编辑事业部'" v-if="openDialog" v-model="openDialog" width="900">
+      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
+        <template #status>
+          <div style="width: 100%">
+            <el-radio-group v-model="formData.data.status">
+              <el-radio v-for="(item, index) in status" :key="index" :label="item.dictKey">{{ item.dictValue }}</el-radio>
+            </el-radio-group>
+          </div>
+        </template>
+      </byForm>
+      <template #footer>
+        <el-button @click="openDialog = false" size="large">取 消</el-button>
+        <el-button type="primary" @click="submitForm()" :disabled="btnDisabled" size="large">确 定</el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup>
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import { ElMessage, ElMessageBox } from "element-plus";
+
+const { proxy } = getCurrentInstance();
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 0,
+    pageNum: 1,
+    pageSize: 10,
+    name: "",
+    priceSystemId: "",
+    contactPerson: "",
+  },
+});
+const loading = ref(false);
+const searchConfig = computed(() => {
+  return [
+    {
+      type: "input",
+      prop: "name",
+      label: "事业部",
+    },
+    {
+      type: "select",
+      prop: "priceSystemId",
+      label: "售价体系",
+      data: [],
+    },
+    {
+      type: "input",
+      prop: "contactPerson",
+      label: "联系人",
+    },
+  ];
+});
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "群组品号",
+        prop: "name",
+        width: 180,
+      },
+    },
+    {
+      attrs: {
+        label: "群组品名",
+        prop: "name",
+        "min-width": 240,
+      },
+    },
+    // {
+    //   attrs: {
+    //     label: "产品来源",
+    //     prop: "source",
+    //     width: 120,
+    //   },
+    //   render(val) {
+    //     return val == 1 ? "MES" : "万里牛";
+    //   },
+    // },
+    // {
+    //   attrs: {
+    //     label: "品牌",
+    //     prop: "brand",
+    //     width: 120,
+    //   },
+    //   render(val) {
+    //     return proxy.dictKeyValue(val, proxy.useUserStore().allDict["wlnBrand"]);
+    //   },
+    // },
+    // {
+    //   attrs: {
+    //     label: "型号",
+    //     prop: "modelNumber",
+    //     width: 200,
+    //   },
+    // },
+    // {
+    //   attrs: {
+    //     label: "材质",
+    //     prop: "material",
+    //     width: 200,
+    //   },
+    // },
+    {
+      attrs: {
+        label: "操作",
+        width: 120,
+        align: "center",
+        fixed: "right",
+      },
+      renderHTML(row) {
+        return [
+          {
+            attrs: {
+              label: "编辑",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              clickUpdate(row);
+            },
+          },
+          {
+            attrs: {
+              label: "删除",
+              type: "danger",
+              text: true,
+            },
+            el: "button",
+            click() {
+              clickDelete(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("/department/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 = () => {
+  treeCategory.value.setCurrentKey(null);
+  getList("", true);
+};
+const modalType = ref("add");
+const openDialog = ref(false);
+const submit = ref(null);
+const status = ref([
+  {
+    dictKey: 1,
+    dictValue: "启用",
+  },
+  {
+    dictKey: 0,
+    dictValue: "禁用",
+  },
+]);
+const formOption = reactive({
+  inline: true,
+  labelWidth: "120px",
+  itemWidth: 100,
+  rules: [],
+  labelPosition: "right",
+});
+const formData = reactive({
+  data: {
+    status: 1,
+    wlnWarehouseCodeArr: [],
+    wlnBrandArr: [],
+  },
+});
+const formConfig = computed(() => {
+  return [
+    {
+      type: "title",
+      title: "账号密码",
+      label: "",
+    },
+    {
+      type: "input",
+      prop: "adminUsername",
+      label: "管理员账号",
+      itemType: "text",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "adminPassword",
+      label: "管理员密码",
+      itemType: "text",
+      itemWidth: 50,
+    },
+    {
+      type: "title",
+      title: "基本信息",
+      label: "",
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "事业部",
+      itemType: "text",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "telephone",
+      label: "事业部电话",
+      itemType: "text",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "address",
+      label: "事业部地址",
+      itemType: "text",
+    },
+    {
+      type: "input",
+      prop: "contactPerson",
+      label: "联系人",
+      itemType: "text",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "contactNumber",
+      label: "联系人电话",
+      itemType: "text",
+      itemWidth: 50,
+    },
+    {
+      type: "select",
+      prop: "priceSystemId",
+      label: "售价体系",
+      itemWidth: 50,
+      data: [],
+    },
+    {
+      type: "select",
+      label: "下单模式",
+      prop: "orderMode",
+      data: proxy.useUserStore().allDict["department_orderMode"],
+      itemWidth: 50,
+    },
+    {
+      type: "select",
+      label: "佣金规则",
+      prop: "commissionRule",
+      data: proxy.useUserStore().allDict["department_commissionRule"],
+      itemWidth: 50,
+    },
+    {
+      type: "slot",
+      slotName: "status",
+      prop: "status",
+      label: "状态",
+    },
+    {
+      type: "title",
+      title: "信用",
+      label: "",
+    },
+    {
+      type: "number",
+      prop: "lineCredit",
+      label: "信用额度",
+      itemType: "text",
+      itemWidth: 50,
+      min: 0,
+      controls: false,
+    },
+    {
+      type: "input",
+      prop: "usedCredit",
+      label: "已用额度",
+      itemType: "text",
+      itemWidth: 50,
+      disabled: true,
+      placeholder: " ",
+    },
+    {
+      type: "title",
+      title: "万里牛对接",
+      label: "",
+    },
+    {
+      type: "select",
+      label: "万里牛仓库编码",
+      prop: "wlnWarehouseCodeArr",
+      data: proxy.useUserStore().allDict["wlnWarehouseCoding"],
+      multiple: true,
+    },
+    {
+      type: "select",
+      label: "万里牛品牌",
+      prop: "wlnBrandArr",
+      data: proxy.useUserStore().allDict["wlnBrand"],
+      multiple: true,
+    },
+  ];
+});
+const rules = ref({
+  adminUsername: [{ required: true, message: "请输入管理员账号", trigger: "blur" }],
+  adminPassword: [{ required: true, message: "请输入管理员密码", trigger: "blur" }],
+  name: [{ required: true, message: "请输入事业部", trigger: "blur" }],
+  telephone: [{ required: true, message: "请输入事业部电话", trigger: "blur" }],
+  address: [{ required: true, message: "请输入事业部地址", trigger: "blur" }],
+  contactPerson: [{ required: true, message: "请输入联系人", trigger: "blur" }],
+  contactNumber: [{ required: true, message: "请输入联系人电话", trigger: "blur" }],
+  orderMode: [{ required: true, message: "请选择下单模式", trigger: "change" }],
+  status: [{ required: true, message: "请选择状态", trigger: "change" }],
+});
+const btnDisabled = ref(false);
+const clickModal = () => {
+  modalType.value = "add";
+  formData.data = {
+    status: 1,
+    wlnWarehouseCodeArr: [],
+    wlnBrandArr: [],
+  };
+  btnDisabled.value = false;
+  openDialog.value = true;
+};
+const submitForm = () => {
+  submit.value.handleSubmit(() => {
+    if (formData.data.wlnBrandArr && formData.data.wlnBrandArr.length > 0) {
+      formData.data.wlnBrand = formData.data.wlnBrandArr.join(",");
+    } else {
+      formData.data.wlnBrand = "";
+    }
+    if (formData.data.wlnWarehouseCodeArr && formData.data.wlnWarehouseCodeArr.length > 0) {
+      formData.data.wlnWarehouseCode = formData.data.wlnWarehouseCodeArr.join(",");
+    } else {
+      formData.data.wlnWarehouseCode = "";
+    }
+    btnDisabled.value = true;
+    proxy.post("/department/" + modalType.value, formData.data).then(
+      () => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        openDialog.value = false;
+        btnDisabled.value = false;
+        getList();
+      },
+      (err) => {
+        console.log(err);
+        btnDisabled.value = false;
+      }
+    );
+  });
+};
+const clickUpdate = (row) => {
+  modalType.value = "edit";
+  formData.data = row;
+  if (formData.data.wlnBrand) {
+    formData.data.wlnBrandArr = formData.data.wlnBrand.split(",");
+  } else {
+    formData.data.wlnBrandArr = [];
+  }
+  if (formData.data.wlnWarehouseCode) {
+    formData.data.wlnWarehouseCodeArr = formData.data.wlnWarehouseCode.split(",");
+  } else {
+    formData.data.wlnWarehouseCodeArr = [];
+  }
+  btnDisabled.value = false;
+  openDialog.value = true;
+};
+const clickDelete = (row) => {
+  ElMessageBox.confirm("你是否确认此操作", "提示", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning",
+  }).then(() => {
+    proxy.post("/department/delete", { id: row.id }).then(() => {
+      ElMessage({ message: "删除成功", type: "success" });
+      getList();
+    });
+  });
+};
+</script>
+
+<style lang="scss" scoped>
+::v-deep(.el-input-number .el-input__inner) {
+  text-align: left;
+}
+</style>