asd26269546 před 1 rokem
rodič
revize
a297dbd9d9

+ 1 - 3
src/views/login.vue

@@ -216,18 +216,16 @@ const ddLoginInit = () => {
 			corpId: route.query.id, // 企业id
 			onSuccess: function (info) {
 				code.value = info.code
-				
 				proxy
 					.post('/open/dingApi/getUserToken', { code: code.value,corpId:route.query.id })
 					.then((res) => {
 						window.localStorage.setItem('corpId',route.query.id)
-						
 						setToken(res.data)
 						getInfo()
 					})
 			},
 			onFail: function (err) {
-			
+				
 			},
 		})
 	})

+ 1 - 1
src/views/product-material/product-library/index.vue

@@ -98,11 +98,11 @@ const getList = (type) => {
       res.data.rows = res.data.rows.map((item) => {
         return {
           ...item,
-          productClassifyName: item.classifyNameGroup.join(" / "),
         };
       });
       listData.value = type === "refresh" ? res.data.rows : listData.value.concat(res.data.rows);
       if (req.value.pageNum * 10 >= res.data.total) {
+        
         finished.value = true;
       }
       req.value.pageNum++;

+ 205 - 0
src/views/product-material/standard-product-library/add.vue

@@ -0,0 +1,205 @@
+<template>
+	<div class="form">
+		<van-nav-bar
+			:title="$t('productLibrary.name')"
+			:left-text="$t('common.back')"
+			left-arrow
+			@click-left="onClickLeft"
+		>
+		</van-nav-bar>
+		
+    <testForm
+      v-model="formData.data"
+      :formOption="formOption"
+      :formConfig="formConfig"
+      :rules="rules"
+      @onSubmit="onSubmit"
+      ref="formDom"
+    ></testForm>
+	</div>
+</template>
+
+<script setup>
+import { ref, getCurrentInstance, onMounted,reactive } from "vue";
+import { showSuccessToast, showToast } from "vant";
+import { useRoute } from "vue-router";
+import { getUserInfo } from '@/utils/auth';
+import testForm from "@/components/testForm/index.vue";
+const proxy = getCurrentInstance().proxy;
+const route = useRoute();
+const show = ref(false);
+const typeModal = ref(false);
+const unitModal = ref(false);
+const classification = ref([]);
+const formData = reactive({
+  data: {
+  },
+});
+const formDom = ref(null);
+const formOption = reactive({
+  readonly: false, //用于控制整个表单是否只读
+  disabled: false,
+  labelAlign: "top",
+  scroll: true,
+  labelWidth: "62pk",
+  // hiddenSubmitBtn: true,
+});
+const formConfig = reactive([
+  {
+    type: "cascader",
+    label: proxy.t('productLibrary.productClassification'),
+    prop: "productClassifyId",
+    itemType: "common",
+    showPicker: false,
+    // data: classification.value,
+    data: [],
+    fieldNames: {
+      text: "label",
+      value: "id",
+      children: "children",
+    },
+    // onChangeFn: (option) => {
+    //   // console.log("aa");
+    // },
+    // finishFn: (current, option) => {
+    //   current.showPicker = false;
+    // },
+  },
+  {
+    type: "picker",
+    label: proxy.t('productLibrary.productType'),
+    prop: "type",
+    itemType: "onePicker",
+    showPicker: false,
+    fieldNames: {
+      text: "label",
+      value: "id",
+    },
+    data: [
+      {
+        label: proxy.t('productLibrary.finishedProduct'),
+        id: "10",
+      },
+      {
+        label: proxy.t('productLibrary.semifinishedProduct'),
+        id: "2",
+      },
+    ],
+  },
+  {
+    type: "input",
+    itemType: "text",
+    label: proxy.t('productLibrary.productName'),
+    prop: "name",
+    clearable: true,
+  },
+  {
+    type: "input",
+    itemType: "text",
+    label: proxy.t('productLibrary.specificationModel'),
+    prop: "spec",
+    clearable: true,
+  },
+  {
+    type: "picker",
+    label: proxy.t('productLibrary.unit'),
+    prop: "unit",
+    itemType: "onePicker",
+    showPicker: false,
+    fieldNames: {
+      text: "dictValue",
+      value: "dictKey",
+    },
+    data: []
+  },
+  {
+    type: "upload",
+    label: proxy.t('productLibrary.fileUpload'),
+    prop: "fileList",
+  },
+  {
+    type: "input",
+    itemType: "textarea",
+    label: proxy.t('productLibrary.remarks'),
+    prop: "remark",
+  },
+]);
+const rules = {
+  productClassifyId: [{ required: true, message: proxy.t('productLibrary.productClassificationCanNotBeEmpty') }],
+  type: [{ required: true, message: proxy.t('productLibrary.productTypeCanNotBeEmpty') }],
+  name: [{ required: true, message: proxy.t('productLibrary.productNameCanNotBeEmpty') }],
+  spec: [{ required: true, message: proxy.t('productLibrary.specificationModelCanNotBeEmpty') }],
+  unit: [{ required: true, message: proxy.t('productLibrary.unitCanNotBeEmpty') }],
+  select: [{ required: true, message: proxy.t('productLibrary.pleaseSelect') }],
+  date: [{ required: true, message: proxy.t('productLibrary.pleaseSelectTime') }],
+  common: [{ required: true, message: proxy.t('productLibrary.pleaseSelectCascader') }],
+  // city: [{ required: true, message: "请选择城市" }],
+};
+const unitList = ref([]);
+
+const getDict = () => {
+  proxy
+    .post("/dictTenantData/page", {
+      pageNum: 1,
+      pageSize: 999,
+      tenantId: getUserInfo().tenantId,
+      dictCode: "unit",
+    })
+    .then((res) => {
+      formConfig[4].data = res.data.rows
+    })
+}
+getDict()
+const fileList = ref([]);
+const onClickLeft = () => history.back();
+const onSubmit = () => {
+  console.log(formData)
+  
+  proxy.post("/productInfo/" + route.query.type, formData.data).then(() => {
+    showSuccessToast(proxy.t('common.addSuccess'));
+    setTimeout(() => {
+      history.back();
+    }, 500);
+  });
+};
+const treeToList = (arr) => {
+  let res = []; // 用于存储递归结果(扁平数据)
+  // 递归函数
+  let fn = (source) => {
+    source.forEach((el) => {
+      res.push(el);
+      el.children && el.children.length > 0 ? fn(el.children) : ""; // 子级递归
+    });
+  };
+  fn(arr);
+  return res;
+};
+onMounted(() => {
+  proxy.post("/productClassify/tree", { parentId: "", name: "", definition: "1" }).then((res) => {
+    formConfig[0].data = res.data;
+    let classList = treeToList(res.data);
+    if (route.query.id) {
+      proxy.post("/productInfo/detail", { id: route.query.id }).then((resDetail) => {
+        formData.data = resDetail.data
+        
+      });
+      // proxy.post("/fileInfo/getList", { businessIdList: [route.query.id] }).then((res) => {
+      //   if (res.data[route.query.id] && res.data[route.query.id].length > 0) {
+      //     formData.value.fileList = res.data[route.query.id];
+      //     fileList.value = res.data[route.query.id].map((item) => {
+      //       return {
+      //         ...item,
+      //         url: item.fileUrl,
+      //       };
+      //     });
+      //   } else {
+      //     formData.value.fileList = [];
+      //     fileList.value = [];
+      //   }
+      // });
+    }else {
+      
+    }
+  });
+});
+</script>

+ 122 - 0
src/views/product-material/standard-product-library/index.vue

@@ -0,0 +1,122 @@
+<template>
+    <van-nav-bar :title="$t('productLibrary.name')" left-text="" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
+      <template #right> {{$t('common.add')}} </template>
+    </van-nav-bar>
+    <van-search v-model="req.keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
+    <van-pull-refresh v-model="loading" @refresh="onRefresh">
+      <div class="list">
+        <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="onLoad" style="margin-bottom: 60px">
+          <commonList :data="listData" @onClick="toDtl" :config="listConfig"></commonList>
+        </van-list>
+      </div>
+    </van-pull-refresh>
+  </template>
+  <script setup>
+  import { ref, getCurrentInstance } from "vue";
+  import commonList from "@/components/common-list.vue";
+  import { useRoute } from "vue-router";
+  
+  const loading = ref(false);
+  const router = useRoute();
+  const req = ref({
+    pageNum: 1,
+    keyword: null,
+    definition: "1",
+  });
+  const finished = ref(false);
+  const proxy = getCurrentInstance().proxy;
+  const listData = ref([]);
+  const classification = ref([]);
+  const listConfig = ref([
+    {
+      label: proxy.t('productLibrary.productClassification'),
+      prop: "productClassifyName",
+    },
+    {
+      label: proxy.t('productLibrary.productCode'),
+      prop: "code",
+    },
+    {
+      label: proxy.t('productLibrary.productName'),
+      prop: "name",
+    },
+  ]);
+  const onRefresh = () => {
+    req.value.pageNum = 1;
+    finished.value = false;
+    getList("refresh");
+  };
+  const onLoad = () => {
+    getClassification();
+  };
+  const onClickLeft = () => proxy.$router.push("/main/working");
+  const onClickRight = () => {
+    proxy.$router.push({
+      path: "productLibraryAdd",
+      query: {
+          type: 'add'
+      },
+    });
+  };
+  proxy.uploadDdRightBtn(onClickRight,proxy.t('common.add'))
+  const toDtl = (row) => {
+    proxy.$router.push({
+      path: "productLibraryAdd",
+      query: {
+        id: row.id,
+        type: 'edit'
+      },
+    });
+  };
+  const treeToList = (arr) => {
+    let res = []; // 用于存储递归结果(扁平数据)
+    // 递归函数
+    let fn = (source) => {
+      source.forEach((el) => {
+        res.push(el);
+        el.children && el.children.length > 0 ? fn(el.children) : ""; // 子级递归
+      });
+    };
+    fn(arr);
+    return res;
+  };
+  const getClassification = () => {
+    if (classification.value && classification.value.length > 0) {
+      getList();
+    } else {
+      proxy.post("/productClassify/tree", { parentId: "", name: "", definition: "1" }).then((res) => {
+        classification.value = treeToList(res.data);
+        getList();
+      });
+    }
+  };
+  const getList = (type) => {
+    loading.value = true;
+    proxy
+      .post("/productInfo/page", req.value)
+      .then((res) => {
+        res.data.rows = res.data.rows.map((item) => {
+          return {
+            ...item,
+          };
+        });
+        listData.value = type === "refresh" ? res.data.rows : listData.value.concat(res.data.rows);
+        if (req.value.pageNum * 10 >= res.data.total) {
+          
+          finished.value = true;
+        }
+        req.value.pageNum++;
+        loading.value = false;
+      })
+      .catch((err) => {
+        loading.value = false;
+      });
+  };
+  </script>
+  
+  <style lang="scss" scoped>
+  .list {
+    min-height: 70vh;
+  }
+  </style>
+