002201 1 年之前
父节点
当前提交
c54ecb23b0

+ 17 - 18
src/components/popover-select-v2/multiple.vue

@@ -17,7 +17,7 @@ export default {
     },
     // 作为 value 唯一标识的键名,绑定值
     valueKey: {
-      type: [String, Array],
+      type: [String, null, undefined],
     },
     // 默认查询参数
     queryParams: {
@@ -62,14 +62,23 @@ export default {
         this.$emit("input", value);
       },
     },
-    tableColumns() {
-      const { referName } = this.$props;
-      return require(`../popover-select/components/${referName}`).default.filter(
-        (document) => document.key
-      );
+    tableColumns: {
+      get() {
+        const { referName } = this.$props;
+        const {
+          default: d,
+        } = require(`../popover-select/components/${referName}`);
+        return d.filter(({ key }) => key);
+      },
+    },
+  },
+  watch: {
+    innerValue: {
+      handler: function (newValue) {
+        if (!newValue) this.lastSelectData = [];
+      },
     },
   },
-  watch: {},
   methods: {
     // open dialog
     async open() {
@@ -138,16 +147,6 @@ export default {
       if (typeof valueKey === "string") {
         this.innerValue = prop.map((item) => item[valueKey]);
       }
-      // array
-      else if (Array.isArray(valueKey)) {
-        this.innerValue = prop.map((item) => {
-          const object = {};
-          valueKey.forEach((cItem) => {
-            object[cItem] = item[cItem];
-          });
-          return object;
-        });
-      }
       // null
       else {
         this.innerValue = prop;
@@ -281,7 +280,7 @@ export default {
         @close="useDelete(index)"
         style="margin-right: 5px"
       >
-        {{ tag[valueKey] }}
+        {{ tag.name || tag[valueKey] }}
       </el-tag>
     </el-scrollbar>
   </div>

+ 8 - 4
src/utils/request.js

@@ -28,7 +28,8 @@ service.interceptors.request.use(
     // 是否需要防止数据重复提交
     const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
     // 是否存在列表查询
-    const isQueryList = config.url.includes("/list") || config.url.includes("/query");
+    const isQueryList =
+      config.url.includes("/list") || config.url.includes("/query");
     if (getToken() && !isToken) {
       config.headers["Authorization"] = "Bearer " + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
     }
@@ -40,7 +41,8 @@ service.interceptors.request.use(
       config.url = url;
     }
     if (
-      !isRepeatSubmit && !isQueryList &&
+      !isRepeatSubmit &&
+      !isQueryList &&
       (config.method === "post" || config.method === "put")
     ) {
       const requestObj = {
@@ -90,7 +92,10 @@ service.interceptors.response.use(
     // 未设置状态码则默认成功状态
     const code = res.data.code || 200;
     // 获取错误信息
-    const msg = errorCode[code] || res.data.msg || errorCode["default"];
+    const msg =
+      errorCode[code] ||
+      res.data.msg.replaceAll(/(\n|\r|\r\n|↵)/g, "<br/>") ||
+      errorCode["default"];
     // 二进制数据则直接返回
     if (
       res.request.responseType === "blob" ||
@@ -130,7 +135,6 @@ service.interceptors.response.use(
       // Message({ message: msg, type: "warning" });
       return Promise.reject("error");
     } else if (code !== 200) {
-      console.log("code", code);
       Notification.error({ title: msg });
       return Promise.reject("error");
     } else {

+ 14 - 3
src/views/purchase/task/column.js

@@ -2,7 +2,7 @@ export const TableColumns = [
   { item: { key: "code", title: "订单生成单号" }, attr: {} },
   {
     item: { key: "status", title: "状态" },
-    attr: { dictName: "purchase_task_status" },
+    attr: { is: "el-dict-tag", dictName: "purchase_task_status" },
   },
   { item: { key: "demandCode", title: "需求单号" }, attr: {} },
   { item: { key: "materialName", title: "物料" }, attr: {} },
@@ -14,7 +14,7 @@ export const TableColumns = [
   { item: { key: "residueQty", title: "未执行数量" }, attr: {} },
   {
     item: { key: "priceType", title: "价格类型" },
-    attr: { dictName: "sys_price_type" },
+    attr: { is: "el-dict-tag", dictName: "sys_price_type" },
   },
   { item: { key: "puUnitName", title: "采购单位" }, attr: {} },
   { item: { key: "buyerName", title: "采购员" }, attr: {} },
@@ -31,7 +31,7 @@ export const TableColumns = [
   { item: { key: "demandDeptName", title: "需求部门" }, attr: {} },
   {
     item: { key: "isBack", title: "是否退回" },
-    attr: { dictName: "sys_yes_no" },
+    attr: { is: "el-dict-tag", dictName: "sys_yes_no" },
   },
   { item: { key: "baskCause", title: "退回原因" }, attr: {} },
   { item: { key: "backDate", title: "退回日期" }, attr: {} },
@@ -161,6 +161,17 @@ export const SearchColumns = [
       placeholder: "请输入来源单据号,多个用,分隔",
     },
   },
+  {
+    item: {
+      key: "materialCodes",
+      title: "物料编码",
+      span: 12,
+    },
+    attr: {
+      is: "el-input",
+      placeholder: "请输入物料编码,多个用,分隔",
+    },
+  },
 ];
 
 const pickerOptions = {

+ 29 - 26
src/views/purchase/task/index.vue

@@ -13,6 +13,7 @@ export default {
     ShiftModel: () => import("./modify-buyer/index.vue"),
     DirectModel: () => import("./first-direct/index.vue"),
     ReturnModel: () => import("./documents-return/index.vue"),
+    ElDictTag: () => import("@/components/DictTag/index.vue"),
     ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
     ElPopoverMultipleSelectV2: () =>
       import("@/components/popover-select-v2/multiple.vue"),
@@ -71,16 +72,22 @@ export default {
     // 查 询
     async useQuery(prop, page) {
       const { pageNum, pageSize } = page;
-      const { date, documentsCodes: code } = prop;
+      const { date, documentsCodes: dCode, materialCodes: mCode } = prop;
       const [startDate, endDate] = date || [];
-      const documentsCodes = code
-        ? code.replace(/\s*/g, "").replaceAll(",", ",")
+      const documentsCodes = dCode
+        ? dCode.replace(/\s*/g, "").replaceAll(",", ",")
+        : undefined;
+      const materialCodes = Array.isArray(mCode)
+        ? mCode
+        : mCode
+        ? mCode.replace(/\s*/g, "").replaceAll(",", ",").split(",")
         : undefined;
       await this.fetchList(
         {
           ...prop,
           endDate,
           startDate,
+          materialCodes,
           documentsCodes,
           date: undefined,
         },
@@ -179,8 +186,8 @@ export default {
     >
       <el-row :gutter="20">
         <el-col
-          v-for="column in searchColumns"
-          :key="column.item.title"
+          v-for="(column, index) in searchColumns"
+          :key="index"
           :span="column.item.span || 6"
         >
           <el-form-item :prop="column.item.key" :label="column.item.title">
@@ -211,9 +218,6 @@ export default {
         查 询
       </el-button>
       <el-button :size="size" @click="useReset"> 重 置 </el-button>
-      <!-- <el-button :size="size" @click="useExport(params, page)">
-        导 出
-      </el-button> -->
       <el-button
         v-show="hasPowerShift(selectData)"
         :size="size"
@@ -228,13 +232,6 @@ export default {
       >
         退回需求
       </el-button>
-      <!-- <el-button
-          :size="size"
-          :disabled="selectData.length !== 1"
-          @click="useClose(selectData[0])"
-        >
-          行关闭
-        </el-button> -->
       <el-button
         v-show="hasPowerDirect(selectData)"
         :size="size"
@@ -259,24 +256,27 @@ export default {
         :selectable="setSelectable"
       >
       </el-table-column>
+      <el-table-column width="55" align="center" type="index">
+        <template slot-scope="scope">
+          {{ scope.row.$index }}
+        </template>
+      </el-table-column>
       <el-table-column
-        v-for="(column, index) in tableColumns"
+        v-for="({ item, attr }, index) in tableColumns"
         :key="index"
-        :prop="column.item.key"
-        :label="column.item.title"
-        :width="column.item.width || 200"
+        :prop="item.key"
+        :label="item.title"
+        :width="item.width || 250"
         show-overflow-tooltip
       >
         <template slot-scope="scope">
           <dict-tag
-            v-if="column.attr.dictName"
+            v-if="attr.dictName"
             :size="size"
-            :value="scope.row[column.item.key]"
-            :options="$dicts[column.attr.dictName]"
+            :value="scope.row[item.key]"
+            :options="$dicts[attr.dictName]"
           />
-          <component is="span" v-else>{{
-            scope.row[column.item.key]
-          }}</component>
+          <component is="span" v-else>{{ scope.row[item.key] }}</component>
         </template>
       </el-table-column>
     </el-table>
@@ -288,7 +288,6 @@ export default {
     />
   </el-card>
 </template>
-
 <style scoped lang="scss">
 .el-card {
   width: calc(100% - 20px);
@@ -309,6 +308,10 @@ export default {
     .el-table__cell {
       height: 50px;
     }
+    td.el-table__cell {
+      border-right: 0;
+      // border-bottom: 0;
+    }
   }
 }
 </style>