Browse Source

Merge branch 'master' of http://36.137.93.232:3000/hf/byte-sailing-new

lxf 1 year ago
parent
commit
06995ac03a

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

@@ -102,6 +102,7 @@
           value-key="id"
           :placeholder="i.placeholder || '请选择'"
           check-strictly
+           :style="i.style"
         />
         <el-date-picker
           v-model="formData[i.prop]"

+ 1 - 0
src/components/product/treeList.vue

@@ -25,6 +25,7 @@
         node-key="id"
         @node-click="treeChange"
         default-expand-all
+        :expand-on-click-node="false"
         :filter-node-method="filterNode"
       >
         <template #default="{ node, data }">

+ 752 - 0
src/views/EHSD/productLibrary/companyProduct/index.vue

@@ -0,0 +1,752 @@
+<template>
+  <div class="user">
+    <div class="tree">
+      <treeList
+        title="产品分类"
+        submitType="1"
+        :data="treeListData"
+        v-model="sourceList.pagination.productClassifyId"
+        @change="treeChange"
+        @changeTreeList="getTreeList"
+      >
+      </treeList>
+    </div>
+    <div class="content">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        :action-list="[
+          {
+            text: '导入产品库',
+            action: () => openExcel(),
+            disabled: false,
+          },
+          {
+            text: '新增',
+            action: () => openModal('add'),
+            disabled: false,
+          },
+        ]"
+        @get-list="getList"
+      >
+        <template #pic="{ item }">
+          <div v-if="item.fileList.length > 0">
+            <img
+              :src="item.fileList[0].fileUrl"
+              class="pic"
+              @click="handleClickFile(item.fileList[0])"
+            />
+          </div>
+          <div v-else></div>
+        </template>
+      </byTable>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '添加产品' : '编辑产品'"
+      v-model="dialogVisible"
+      width="90%"
+      v-loading="loading"
+      destroy-on-close
+    >
+      <div class="public_height_dialog">
+        <byForm
+          :formConfig="formConfig"
+          :formOption="formOption"
+          v-model="formData.data"
+          :rules="rules"
+          ref="byform"
+        >
+          <template #productPic>
+            <div>
+              <el-upload
+                v-model:fileList="fileList"
+                action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
+                :data="uploadData"
+                list-type="picture-card"
+                :on-remove="handleRemove"
+                :on-success="handleSuccess"
+                :before-upload="handleBeforeUpload"
+                accept=".gif, .jpeg, .jpg, .png"
+              >
+                <el-icon><Plus /></el-icon>
+              </el-upload>
+            </div>
+          </template>
+
+          <template #detailDec>
+            <div style="width: 100%">
+              <Editor
+                :value="formData.data.content"
+                @updateValue="updateContent"
+              />
+            </div>
+          </template>
+        </byForm>
+      </div>
+
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+    <el-dialog
+      title="Excel导入"
+      v-model="openExcelDialog"
+      width="400"
+      v-loading="loading"
+    >
+      <template #footer>
+        <el-button @click="openExcelDialog = false" size="large"
+          >取 消</el-button
+        >
+        <el-button
+          type="primary"
+          @click="submitExcel()"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+  
+<script setup>
+/* eslint-disable vue/no-unused-components */
+import { ElMessage, ElMessageBox } from "element-plus";
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import treeList from "@/components/product/treeList";
+import useUserStore from "@/store/modules/user";
+import { computed, defineComponent, ref } from "vue";
+import Editor from "@/components/Editor/index.vue";
+
+const loading = ref(false);
+const submitLoading = ref(false);
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 3,
+    pageNum: 1,
+    pageSize: 10,
+    type: "",
+    productClassifyId: "",
+    keyword: "",
+    definition: "1",
+  },
+});
+let dialogVisible = ref(false);
+let openExcelDialog = ref(false);
+
+let modalType = ref("add");
+let rules = ref({
+  productClassifyId: [
+    { required: true, message: "请选择产品分类", trigger: "change" },
+  ],
+  type: [{ required: true, message: "请选择产品类型", trigger: "change" }],
+  name: [{ required: true, message: "请输入产品名称", trigger: "blur" }],
+  unit: [{ required: true, message: "请选择单位", trigger: "change" }],
+});
+const { proxy } = getCurrentInstance();
+const selectConfig = reactive([
+  {
+    label: "产品类型",
+    prop: "type",
+    data: [],
+  },
+]);
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "图片",
+        prop: "type",
+      },
+      render(type) {
+        return proxy.dictDataEcho(type, productType.value);
+      },
+    },
+    {
+      attrs: {
+        label: "编号",
+        prop: "code",
+      },
+    },
+    {
+      attrs: {
+        label: "名称",
+        prop: "name",
+      },
+    },
+    {
+      attrs: {
+        label: "尺寸",
+        prop: "unit",
+      },
+    },
+    {
+      attrs: {
+        label: "成本价(¥)",
+        prop: "unit",
+      },
+    },
+    {
+      attrs: {
+        label: "销售指导价(¥)",
+        prop: "spec",
+      },
+    },
+    {
+      attrs: {
+        label: "型号",
+        prop: "remark",
+      },
+    },
+    {
+      attrs: {
+        label: "创建人",
+        prop: "remark",
+      },
+    },
+
+    {
+      attrs: {
+        label: "操作",
+        width: "120",
+        align: "center",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          {
+            attrs: {
+              label: "修改",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              getDtl(row);
+            },
+          },
+          {
+            attrs: {
+              label: "删除",
+              type: "danger",
+              text: true,
+            },
+            el: "button",
+            click() {
+              // 弹窗提示是否删除
+              ElMessageBox.confirm(
+                "此操作将永久删除该数据, 是否继续?",
+                "提示",
+                {
+                  confirmButtonText: "确定",
+                  cancelButtonText: "取消",
+                  type: "warning",
+                }
+              ).then(() => {
+                // 删除
+                proxy
+                  .post("/productInfo/delete", {
+                    id: row.id,
+                  })
+                  .then((res) => {
+                    ElMessage({
+                      message: "删除成功",
+                      type: "success",
+                    });
+                    getList();
+                  });
+              });
+            },
+          },
+        ];
+      },
+    },
+  ];
+});
+
+const uploadData = ref({});
+const fileList = ref([]);
+const fileListCopy = ref([]);
+
+let formData = reactive({
+  data: {},
+});
+const formOption = reactive({
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const byform = ref(null);
+const treeListData = ref([]);
+const formConfig = computed(() => {
+  return [
+    {
+      type: "title",
+      title: "基本信息",
+    },
+    {
+      type: "treeSelect",
+      prop: "productClassifyId",
+      label: "类目",
+      data: [],
+      itemWidth: 50,
+      style: {
+        width: "100%",
+      },
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "编码",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "名称(中文)",
+      itemWidth: 100,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "名称(英文)",
+      itemWidth: 100,
+    },
+    {
+      type: "title",
+      title: "价格维护",
+    },
+    {
+      type: "number",
+      prop: "returnPeriod",
+      label: "销售指导价(¥)",
+      itemWidth: 50,
+      controls: false,
+      precision: 2,
+      min: 0,
+      style: {
+        width: "100%",
+      },
+    },
+    {
+      type: "number",
+      prop: "returnPeriod",
+      label: "成本价(¥)",
+      itemWidth: 50,
+      controls: false,
+      precision: 2,
+      min: 0,
+      style: {
+        width: "100%",
+      },
+    },
+    {
+      type: "title",
+      title: "属性字段",
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "材质(中文)",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "材质(英文)",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "型号(中文)",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "型号(英文)",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "样品尺寸",
+      itemWidth: 33.33,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: " ",
+      itemWidth: 33.33,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: " ",
+      itemWidth: 33.33,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "装箱尺寸",
+      itemWidth: 33.33,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: " ",
+      itemWidth: 33.33,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: " ",
+      itemWidth: 33.33,
+    },
+    {
+      type: "select",
+      prop: "type",
+      label: "内包装方式",
+      required: true,
+      itemWidth: 50,
+      data: [],
+      style: {
+        width: "100%",
+      },
+    },
+    {
+      type: "select",
+      prop: "type",
+      label: "外包装方式",
+      required: true,
+      itemWidth: 50,
+      data: [],
+      style: {
+        width: "100%",
+      },
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "净重(kg)",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "毛重(kg)",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "海关编码",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "MOQ",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "采购/销售单位",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "出入库单位",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "换算比例",
+      itemWidth: 50,
+    },
+    {
+      type: "title",
+      title: "仓储字段",
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "安全库存",
+      itemWidth: 50,
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "采购周期",
+      itemWidth: 50,
+    },
+    {
+      type: "radio",
+      prop: "type",
+      label: "先入先出",
+      required: true,
+      border: true,
+      itemWidth: 50,
+      data: [
+        {
+          label: "不启用",
+          value: "1",
+        },
+        {
+          label: "一物一码",
+          value: "2",
+        },
+        {
+          label: "一物一码 & 先入先出",
+          value: "3",
+        },
+      ],
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "质检合格率",
+      itemWidth: 50,
+    },
+    {
+      type: "title",
+      title: "图片介绍",
+    },
+    {
+      type: "slot",
+      slotName: "productPic",
+      prop: "fileList",
+      label: "产品图片",
+    },
+    {
+      type: "slot",
+      slotName: "detailDec",
+      prop: "fileList",
+      label: "详情描述",
+    },
+  ];
+});
+const newPassword = () => {
+  formData.data.password = generatePassword();
+};
+const generatePassword = () => {
+  var length = 12,
+    charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+    password = "";
+  for (var i = 0, n = charset.length; i < length; ++i) {
+    password += charset.charAt(Math.floor(Math.random() * n));
+  }
+  return password;
+};
+
+const getList = async (req) => {
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy
+    .post("/productInfo/page", sourceList.value.pagination)
+    .then((message) => {
+      console.log(message);
+      sourceList.value.data = message.rows.map((x) => ({ ...x, fileList: [] }));
+      sourceList.value.pagination.total = message.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
+
+      const productIdList = message.rows.map((x) => x.id);
+      // 请求文件数据并回显
+      if (productIdList.length > 0) {
+        proxy
+          .post("/fileInfo/getList", { businessIdList: productIdList })
+          .then((fileObj) => {
+            for (let i = 0; i < sourceList.value.data.length; i++) {
+              const e = sourceList.value.data[i];
+              for (const key in fileObj) {
+                if (e.id === key) {
+                  e.fileList = fileObj[key];
+                }
+              }
+            }
+          });
+      }
+    });
+};
+
+const treeChange = (e) => {
+  console.log(e);
+  sourceList.value.pagination.productClassifyId = e.id;
+  getList({ productClassifyId: e.id });
+};
+
+const openModal = () => {
+  dialogVisible.value = true;
+  modalType.value = "add";
+  formData.data = {
+    definition: "1",
+    content:"",
+    // type: "1",
+    fileList: [],
+    standardJson: {},
+  };
+
+  fileList.value = [];
+  fileListCopy.value = [];
+};
+
+const openExcel = () => {
+  openExcelDialog.value = true;
+};
+const submitExcel = () => {
+  openExcelDialog.value = false;
+};
+const TreetenantId = ref("");
+const selection = ref({
+  data: [],
+});
+const select = (_selection, row) => {
+  selection.value.data = _selection;
+  console.log(_selection.length);
+};
+
+const tree = ref(null);
+const submitForm = () => {
+  console.log(byform.value);
+  byform.value.handleSubmit((valid) => {
+    formData.data.fileList = fileListCopy.value.map((x) => ({
+      id: x.id,
+      fileName: x.fileName,
+    }));
+    submitLoading.value = true;
+    proxy.post("/productInfo/" + modalType.value, formData.data).then(
+      (res) => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        dialogVisible.value = false;
+        submitLoading.value = false;
+        getList();
+      },
+      (err) => {
+        submitLoading.value = false;
+      }
+    );
+  });
+};
+
+const getTreeList = () => {
+  proxy
+    .post("/productClassify/tree", { parentId: "", name: "", definition: "1" })
+    .then((message) => {
+      treeListData.value = message;
+      formConfig.value[0].data = message;
+    });
+};
+
+const getDtl = (row) => {
+  modalType.value = "edit";
+  proxy.post("/productInfo/detail", { id: row.id }).then((res) => {
+    fileList.value = row.fileList.map((x) => ({ ...x, url: x.fileUrl }));
+    fileListCopy.value = [...fileList.value];
+    res.type = res.type + ""; //type回显
+    res.definition = "1"; //产品
+    res.standardJson = res.standardJson ? JSON.parse(res.standardJson) : {};
+    formData.data = res;
+    dialogVisible.value = true;
+  });
+};
+getTreeList();
+getList();
+const handleBeforeUpload = async (file) => {
+  const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
+  uploadData.value = res.uploadBody;
+  fileListCopy.value.push({
+    id: res.id,
+    fileName: res.fileName,
+    path: res.fileUrl,
+    url: res.fileUrl,
+    uid: file.uid,
+  });
+};
+
+const handleSuccess = (res, file, files) => {
+  // 查当前file的index值去赋值对应的copy变量的值
+  // let uid = file.uid;
+  // const index = fileList.value.findIndex((x) => x.uid === uid);
+  // fileListCopy.value[index].uid = uid;
+};
+
+const handleRemove = (file) => {
+  const index = fileListCopy.value.findIndex(
+    (x) => x.uid === file.uid || x.id === file.id
+  );
+  fileListCopy.value.splice(index, 1);
+};
+
+const handleClickFile = (file) => {
+  window.open(file.fileUrl, "_blank");
+};
+const productType = ref([]);
+const getDict = () => {
+  proxy.getDictOne(["product_type"]).then((res) => {
+    productType.value = res["product_type"];
+    formConfig.value[1].data = productType.value.map((x) => ({
+      label: x.dictValue,
+      value: x.dictKey,
+    }));
+    selectConfig[0].data = productType.value.map((x) => ({
+      label: x.dictValue,
+      value: x.dictKey,
+    }));
+  });
+};
+getDict();
+const updateContent = (val) => {
+  formData.data.content = val;
+};
+</script>
+  
+<style lang="scss" scoped>
+.user {
+  padding: 20px;
+  display: flex;
+  justify-content: space-between;
+  .tree {
+    width: 300px;
+  }
+  .content {
+    width: calc(100% - 320px);
+  }
+}
+.pic {
+  object-fit: contain;
+  width: 50px;
+  height: 50px;
+  cursor: pointer;
+  vertical-align: middle;
+}
+</style>

+ 13 - 0
src/views/EHSD/productLibrary/customerProduct/index.vue

@@ -0,0 +1,13 @@
+<template>
+  <div>
+    客户产品库
+  </div>
+</template>
+
+<script setup>
+
+</script>
+
+<style lang="scss" scoped>
+
+</style>

+ 1 - 0
src/views/WDLY/basic/product/index.vue

@@ -851,6 +851,7 @@ const getTreeList = () => {
       treeListData.value = message;
     });
 };
+
 const deptList = ref([]);
 const defaultProps = {
   children: "children",

+ 32 - 28
src/views/WDLY/basic/supplier/index.vue

@@ -103,29 +103,16 @@
           </el-row>
         </template>
 
-        <template #contact>
-          <el-row :gutter="10" style="width: 100%">
-            <el-col :span="8">
-              <el-form-item prop="contactPerson">
-                <el-input
-                  v-model="formData.data.contactPerson"
-                  placeholder="联系人"
-                >
-                </el-input>
-              </el-form-item>
-            </el-col>
-            <el-col :span="16">
-              <el-form-item prop="contactNumber">
-                <el-input
-                  v-model="formData.data.contactNumber"
-                  placeholder="联系电话"
-                  :formatter="(val) => val.replace(/[^\d\-]/g, '')"
-                  :parser="(val) => val.replace(/[^\d\-]/g, '')"
-                >
-                </el-input>
-              </el-form-item>
-            </el-col>
-          </el-row>
+        <template #contactNumber>
+          <div style="width: 100%">
+            <el-input
+              v-model="formData.data.contactNumber"
+              placeholder="联系电话"
+              :formatter="(val) => val.replace(/[^\d\-]/g, '')"
+              :parser="(val) => val.replace(/[^\d\-]/g, '')"
+            >
+            </el-input>
+          </div>
         </template>
 
         <template #fileSlot>
@@ -410,15 +397,25 @@ const formConfig = computed(() => {
       label: "地址",
       required: true,
     },
+
     {
-      type: "slot",
-      slotName: "contact",
+      type: "input",
       prop: "contactPerson",
       label: "联系信息",
+      placeholder: "联系人",
       required: true,
+      itemWidth: 30,
     },
     {
       type: "slot",
+      slotName: "contactNumber",
+      prop: "contactNumber",
+      label: " ",
+      itemWidth: 70,
+    },
+
+    {
+      type: "slot",
       slotName: "fileSlot",
       label: "上传附件",
     },
@@ -531,15 +528,22 @@ const submitForm = () => {
         fileName: x.fileName,
       })) || [];
     const obj = JSON.parse(formData.data.victoriatouristJson);
-    console.log(obj, "ss");
-    if (obj.accountPeriod === undefined || obj.accountPeriod === "") {
+    if (
+      obj.accountPeriod === undefined ||
+      obj.accountPeriod === "" ||
+      obj.accountPeriod === null
+    ) {
       formData.data.victoriatouristJson = obj;
       return ElMessage({
         message: "请输入账期!",
         type: "info",
       });
     }
-    if (obj.returnPeriod === undefined || obj.returnPeriod === "") {
+    if (
+      obj.returnPeriod === undefined ||
+      obj.returnPeriod === "" ||
+      obj.returnPeriod === null
+    ) {
       formData.data.victoriatouristJson = obj;
       return ElMessage({
         message: "请输入退换货期限!",

+ 10 - 2
src/views/purchaseManage/supplier/supplyPrice/index.vue

@@ -46,7 +46,11 @@
       >
         <template #details>
           <div style="width: 100%">
-            <el-button type="primary" @click="openProduct = true">
+            <el-button
+              type="primary"
+              @click="openProduct = true"
+              :disabled="modalType == 'edit'"
+            >
               选择
             </el-button>
 
@@ -81,7 +85,11 @@
 
                 <el-table-column prop="zip" label="操作" width="100">
                   <template #default="{ $index }">
-                    <el-button type="primary" link @click="handleRemove($index)"
+                    <el-button
+                      type="primary"
+                      link
+                      @click="handleRemove($index)"
+                      :disabled="modalType == 'edit'"
                       >删除</el-button
                     >
                   </template>