Jelajahi Sumber

Merge branch 'purchaseDev' of http://172.16.100.139/new-business/drp-web into purchaseDev

002390 2 tahun lalu
induk
melakukan
a1c4e1a260

+ 1 - 1
src/api/business/purchase/contract.js

@@ -79,7 +79,7 @@ export function TABLELIST(params, name) {
 
 export function TABLEADD(data, name) {
   return request({
-    url: `${switchUrl(name)}/add`,
+    url: `${switchUrl(name)}`,
     method: "POST",
     data: data,
   });

+ 0 - 7
src/components/computed-input/index.vue

@@ -1,11 +1,4 @@
 <template>
-  <!-- <el-input
-    v-model="value"
-    readonly
-    :size="size"
-    :placeholder="placeholder"
-    style="width: 100%"
-  ></el-input> -->
   <span>{{ value || "- -" }}</span>
 </template>
 

+ 8 - 0
src/components/popover-select/components/MATERIAL_PARAM.js

@@ -29,4 +29,12 @@ export default [
     type: "Input",
     search: true,
   },
+  {
+    key: "registrationNo",
+    title: "注册证号",
+    type: "ComputedInput",
+    computed: (prop) => {
+      return prop.materialMedcine.registrationNo;
+    },
+  },
 ];

+ 85 - 75
src/components/popover-select/index.vue

@@ -1,5 +1,6 @@
 <script>
 import { REFER } from "./api/index";
+import deepCopy from "@gby/deep-copy";
 export default {
   name: "PopoverSelect",
   props: {
@@ -83,9 +84,7 @@ export default {
   data() {
     return {
       width: "50%",
-      page: { pageNum: 1, pageSize: 25, total: 0 },
-      layout: "total, prev, pager, next, sizes, jumper",
-      pageSizes: [25, 50, 100],
+      page: { pageNum: 1, pageSize: 10, total: 0 },
       visible: false,
       loading: false,
       model: {
@@ -94,6 +93,7 @@ export default {
       },
       data: [],
       selectData: [],
+      lastSelectData: [],
     };
   },
   computed: {
@@ -110,16 +110,21 @@ export default {
   watch: {
     "$props.value": {
       handler: function (newProp) {
-        if (!newProp) this.selectData = [];
+        if (!newProp) this.lastSelectData = [];
       },
       immediate: true,
     },
   },
   methods: {
+    //
+    emitChange(prop) {
+      const { type, source, multiple } = this.$props;
+      this.$emit("change", multiple ? prop : prop[0], source, type);
+    },
     // open dialog
     async open() {
       this.visible = true;
-      await this.resetList();
+      await this.useReset();
     },
     // hide dialog
     async hide() {
@@ -140,12 +145,13 @@ export default {
         }
       } catch (err) {
         //
+        console.error(err);
       } finally {
         this.loading = false;
       }
     },
-    // reset list
-    async resetList() {
+    // reset
+    async useReset() {
       const { type, source, queryParams } = this.$props;
       this.model = {
         type,
@@ -155,62 +161,64 @@ export default {
       };
       await this.fetchList(this.model, this.page);
     },
-    // query list
-    async queryList() {
+    // query
+    async useQuery() {
       await this.fetchList(this.model, this.page);
     },
+    // cancel
+    useCancel(prop) {
+      const { multiple } = this.$props;
+      this.useUpdate(multiple ? prop : prop[0]);
+      this.hide();
+    },
+    // confirm
+    useConfirm(prop) {
+      const { multiple } = this.$props;
+      this.useUpdate(multiple ? prop : prop[0]);
+      this.emitChange(this.selectData);
+      this.lastSelectData = deepCopy(this.selectData);
+      this.hide();
+    },
+    // delete
+    useDelete(prop) {
+      this.selectData.splice(prop, 1);
+      this.useUpdate(this.selectData);
+      this.emitChange(this.selectData);
+      this.lastSelectData = deepCopy(this.selectData);
+    },
+    // update
+    useUpdate(prop) {
+      const { source, multiple, valueKey, dataMapping } = this.$props;
+      // update data mapping
+      if (multiple) {
+        const vModel = prop.map((item) => item[valueKey]);
+        this.$emit("input", vModel);
+      } else {
+        const vModel = prop[valueKey];
+        this.$emit("input", vModel);
+        for (let key in dataMapping) {
+          source[key] = prop[dataMapping[key]];
+        }
+        this.$emit("update:source", source);
+      }
+    },
     // row click
-    rowClick(prop) {
+    onceClick(prop) {
       const { multiple } = this.$props;
       // 单选
       if (!multiple) this.$refs.multipleTable.clearSelection();
       [prop].forEach((row) => this.$refs.multipleTable.toggleRowSelection(row));
     },
     // row double click
-    async rowDblclick(prop) {
+    doubleClick(prop) {
       const { multiple } = this.$props;
-      if (!multiple) await this.confirm([prop]);
+      if (!multiple) this.useConfirm([prop]);
     },
     // selection change
     selectionChange(prop) {
-      this.selectData = prop;
-    },
-    // page size change
-    async pageSizeChange(prop) {
-      this.page.pageSize = prop;
-      await this.queryList();
-    },
-    // page number change
-    async pageNumberChange(prop) {
-      this.page.pageNum = prop;
-      await this.queryList();
-    },
-    // confirm
-    async confirm(prop) {
-      const { multiple } = this.$props;
-      await this.hide();
-      await this.update(multiple ? prop : prop[0]);
-    },
-    // delete tag
-    deleteTag(prop) {
-      this.selectData.splice(prop, 1);
-      this.update(this.selectData);
-    },
-    // update
-    update(prop) {
-      const { source, multiple, valueKey, dataMapping, type } = this.$props;
-      // update v-model
-      const vModel = multiple
-        ? prop.map((item) => item[valueKey])
-        : prop[valueKey];
-      this.$emit("input", vModel);
-      // update data mapping
-      for (let key in dataMapping) {
-        source[key] = prop[dataMapping[key]];
+      if (prop && prop.length) {
+        this.selectData = prop;
       }
-      this.$emit("update:source", source);
-      // emit change
-      this.$emit("change", prop, type, source);
     },
   },
   created() {},
@@ -219,7 +227,7 @@ export default {
 };
 </script>
 <template>
-  <div>
+  <div class="popover-select">
     <el-input
       v-model="innerValue"
       :size="size"
@@ -242,7 +250,6 @@ export default {
       :close-on-click-modal="false"
       :close-on-press-escape="false"
       append-to-body
-      @close="hide"
     >
       <el-form
         v-loading="loading"
@@ -254,13 +261,13 @@ export default {
         <el-form-item prop="search">
           <el-input
             v-model="model.search"
-            @change="queryList"
-            @keydown.enter="queryList"
+            @change="useQuery"
+            @keydown.enter="useQuery"
           >
           </el-input>
         </el-form-item>
         <el-form-item>
-          <el-button icon="el-icon-refresh" @click="resetList"></el-button>
+          <el-button icon="el-icon-refresh" @click="useReset"></el-button>
         </el-form-item>
         <el-table
           ref="multipleTable"
@@ -269,11 +276,16 @@ export default {
           height="45vh"
           highlight-current-row
           style="width: 100%; margin-bottom: 20px"
-          @row-click="rowClick"
-          @row-dblclick="rowDblclick"
+          @row-click="onceClick"
+          @row-dblclick="doubleClick"
           @selection-change="selectionChange"
         >
-          <el-table-column width="55" type="selection" align="center">
+          <el-table-column
+            v-if="multiple"
+            width="55"
+            type="selection"
+            align="center"
+          >
           </el-table-column>
           <el-table-column
             v-for="(column, index) in TableColumnTemp"
@@ -296,22 +308,20 @@ export default {
             </template>
           </el-table-column>
         </el-table>
-        <el-pagination
-          :layout="layout"
+        <pagination
           :total="page.total"
-          :page-sizes="pageSizes"
-          :small="size === 'mini'"
-          :page-size="page.pageSize"
-          :current-page="page.pageNum"
-          background
-          @size-change="pageSizeChange"
-          @current-change="pageNumberChange"
-        >
-        </el-pagination>
+          :page.sync="page.pageNum"
+          :limit.sync="page.pageSize"
+          @pagination="useQuery"
+        />
       </el-form>
       <div style="margin-top: 20px; text-align: right">
-        <el-button :size="size" @click="hide"> 取 消 </el-button>
-        <el-button :size="size" @click="confirm(selectData)"> 确 定 </el-button>
+        <el-button :size="size" @click="useCancel(lastSelectData)">
+          取 消
+        </el-button>
+        <el-button :size="size" @click="useConfirm(selectData)">
+          确 定
+        </el-button>
       </div>
     </el-dialog>
     <div
@@ -324,7 +334,7 @@ export default {
         overflow: hidden;
       "
     >
-      <div v-if="multiple && selectData.length">
+      <div v-if="multiple && lastSelectData.length">
         <el-popover
           :offset="-10"
           :width="width"
@@ -335,10 +345,10 @@ export default {
           placement="bottom-start"
         >
           <el-tag slot="reference" :size="size" style="margin-right: 10px">
-            + {{ selectData.length }}
+            + {{ lastSelectData.length }}
           </el-tag>
           <el-tag
-            v-for="(tag, index) in selectData"
+            v-for="(tag, index) in lastSelectData"
             :size="size"
             hit
             closable
@@ -346,9 +356,9 @@ export default {
               display: 'flex',
               justifyContent: 'space-between',
               alignItems: 'center',
-              margin: selectData.length - 1 === index ? '0' : '0 0 5px 0',
+              margin: lastSelectData.length - 1 === index ? '0' : '0 0 5px 0',
             }"
-            @close="deleteTag(index)"
+            @close="useDelete(index)"
           >
             {{ tag.name }}
           </el-tag>

+ 1 - 10
src/components/popover-tree-select/api/index.js

@@ -1,18 +1,9 @@
 import request from "@/utils/request";
 
-export function list(url, params) {
-  return request({
-    url: `/pu/contract/${url}/list`,
-    method: "get",
-    params: params,
-  });
-}
-
-export function refer(data, params) {
+export function REFER(data) {
   return request({
     url: "/refer/query",
     method: "POST",
     data: data,
-    params: params,
   });
 }

+ 0 - 178
src/components/popover-tree-select/components/index.vue

@@ -1,178 +0,0 @@
-<script>
-import { REFER } from "../api/index";
-
-export default {
-  name: "TableDialog",
-  props: ["type", "title", "multiple", "queryParams"],
-  components: {},
-  data() {
-    const { type } = this.$props;
-    const TableColumns = require(`./${type}`).default.filter(
-      (element) => element.key
-    );
-    return {
-      // global
-      size: "mini",
-      width: "50%",
-      // dialog
-      visible: false,
-      loading: false,
-      // search
-      params: { search: "", isPage: true },
-      // table
-      data: [],
-      tableColumns: TableColumns,
-      radio: "",
-      multipleSelection: [],
-      defaultProps: {
-        label: "name",
-        children: "children",
-      },
-    };
-  },
-  computed: {},
-  watch: {},
-  methods: {
-    // set dialog visible
-    setVisible(prop) {
-      this.visible = prop;
-    },
-    // do something before dialog open
-    beforeOpen() {
-      this.radio = "";
-      this.multipleSelection = [];
-      this.fetchList(this.params);
-    },
-    // fetch table data
-    async fetchList(prop) {
-      try {
-        this.loading = true;
-        const { type, queryParams } = this.$props;
-        const { code,rows } = await REFER({
-          type: type,
-          ...prop,
-          ...queryParams,
-        });
-        if (code === 200) {
-          this.data = rows;
-          
-        } else {
-          this.$notify.warning({ title: msg });
-        }
-      } catch (err) {
-        //
-      } finally {
-        this.loading = false;
-      }
-    },
-    // setting up to fetch table data
-    queryList() {
-      this.fetchList(this.params);
-    },
-    // reset to fetch table data
-    resetList() {
-      this.params.search = "";
-      this.fetchList(this.params);
-    },
-    // click select row data
-    handleSelect(data) {
-      this.multipleSelection = [data];
-    },
-    // double click select row data and confirm
-    handleDoubleClickSelect(row) {
-      this.confirm([row]);
-    },
-    // multiple select row data
-    handleMultipleSelect(prop, data) {
-      if (prop) {
-        this.multipleSelection.push(data);
-      } else {
-        const { code } = data;
-        const index = this.multipleSelection.findIndex(
-          (item) => item.code === code
-        );
-        this.multipleSelection.splice(index, 1);
-      }
-    },
-    // confirm
-    confirm(prop) {
-      this.setVisible(false);
-      this.$emit("confirm", prop);
-    },
-  },
-  created() {},
-  mounted() {},
-  destroyed() {},
-};
-</script>
-<template>
-  <el-dialog
-    :title="`${title}(${multiple ? '多选' : '单选'})`"
-    :width="width"
-    :visible.sync="visible"
-    :close-on-click-modal="false"
-    append-to-body
-    destroy-on-close
-    @open="beforeOpen"
-  >
-    <el-form :size="size" :inline="true" :model="params" @submit.native.prevent>
-      <el-form-item prop="search">
-        <el-input
-          v-model="params.search"
-          @keydown.enter="queryList"
-          @change="queryList"
-        >
-        </el-input>
-      </el-form-item>
-      <el-form-item>
-        <el-button icon="el-icon-refresh" @click="resetList"></el-button>
-      </el-form-item>
-    </el-form>
-    <el-tree
-      v-if="multiple"
-      v-loading="loading"
-      :data="data"
-      :props="defaultProps"
-      accordion
-      node-key="id"
-    >
-      <div slot-scope="{ node, data }">
-        <el-checkbox
-          v-model="data.checked"
-          @click.native.stop
-          @change="handleMultipleSelect($event, data)"
-          style="margin: 0 5px 0 0"
-        >
-        </el-checkbox>
-        <span> {{ data.name }}</span>
-      </div>
-    </el-tree>
-    <el-radio-group v-else v-model="radio" style="width: 100%">
-      <el-tree
-        v-loading="loading"
-        :data="data"
-        :props="defaultProps"
-        accordion
-        node-key="id"
-      >
-        <div slot-scope="{ node, data }">
-          <el-radio
-            :label="data.code"
-            @click.native.stop="handleSelect(data)"
-            @dblclick.native.stop="handleDoubleClickSelect(data)"
-            style="margin: 0 5px 0 0"
-          >
-            {{ data.name }}
-          </el-radio>
-        </div>
-      </el-tree>
-    </el-radio-group>
-    <div style="margin-top: 20px; text-align: right">
-      <el-button :size="size" @click="visible = false">取 消</el-button>
-      <el-button :size="size" type="primary" @click="confirm(multipleSelection)"
-        >确 定</el-button
-      >
-    </div>
-  </el-dialog>
-</template>
-<style scoped></style>

+ 213 - 80
src/components/popover-tree-select/index.vue

@@ -1,4 +1,6 @@
 <script>
+import { REFER } from "./api/index";
+import deepCopy from "@gby/deep-copy";
 export default {
   name: "PopoverTreeSelect",
   props: {
@@ -20,16 +22,12 @@ export default {
     // 作为 value 唯一标识的键名,绑定值
     valueKey: {
       type: String,
-      default: "name",
-    },
-    // 作为 value 唯一标识的键名,显示值
-    showKey: {
-      type: String,
+      default: "code",
     },
     // 默认查询参数
     queryParams: {
-      type: Object,
-      default: () => ({}),
+      type: Function,
+      default: () => {},
     },
     // 组件大小
     size: {
@@ -66,99 +64,242 @@ export default {
     // 参照内外映射
     dataMapping: Object,
   },
-  components: {
-    TableDialog: () => import("./components/index.vue"),
-  },
+  components: {},
   data() {
     return {
-      // popover宽度
-      width: "",
-      // 选中data
+      width: "50%",
+      visible: false,
+      loading: false,
+      params: {
+        search: "",
+        isPage: true,
+      },
       data: [],
+      selectData: [],
+      lastSelectData: [],
+      defaultProps: {
+        label: "name",
+        children: "children",
+      },
     };
   },
   computed: {
-    showValue() {
-      const { showKey, valueKey } = this.$props;
-      return this.data.length === 1 ? this.data[0][showKey || valueKey] : "";
+    innerValue() {
+      const { value, multiple } = this.$props;
+      return multiple ? "" : value;
+    },
+    TableColumnTemp() {
+      const { type } = this.$props;
+      const documents = require(`./components/${type}`).default;
+      return documents.filter((document) => document.key);
     },
   },
   watch: {
     "$props.value": {
-      handler: function (newProp, oldProp) {
-        if (!newProp) {
-          this.data = [];
-        }
+      handler: function (newProp) {
+        if (!newProp) this.lastSelectData = [];
       },
       immediate: true,
     },
   },
   methods: {
-    // 打开弹窗
-    handleAsyncOpenDialog() {
-      this.$nextTick(() => {
-        const { setVisible } = this.$refs.TableDialog;
-        setVisible(true);
-      });
-    },
-    // 新增操作
-    handleAdd(prop) {
-      this.data = prop;
-      this.handleUpdate(this.data);
-    },
-    // 删除操作
-    handleDelete(prop) {
-      this.data.splice(prop, 1);
-      this.handleUpdate(this.data);
-    },
-    // 更新操作
-    handleUpdate(prop) {
-      const { source, multiple, valueKey, dataMapping } = this.$props;
-      // 多选
-      if (multiple) {
-        const updateData = prop.map((item) => item[valueKey]);
-        this.$emit("input", updateData);
+    //
+    emitChange(prop) {
+      const { type, source, multiple } = this.$props;
+      this.$emit("change", multiple ? prop : prop[0], source, type);
+    },
+    // open dialog
+    async open() {
+      this.visible = true;
+      await this.useReset();
+    },
+    // hide dialog
+    async hide() {
+      this.visible = false;
+    },
+    // fetch list
+    async fetchList(prop) {
+      try {
+        this.loading = true;
+        const { code, rows } = await REFER(prop);
+        if (code === 200) {
+          this.data = rows;
+        }
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.loading = false;
       }
-      // 单选
-      if (!multiple) {
-        const updateData = prop[0][valueKey];
-        this.$emit("input", updateData);
-        // 更新映射数据
+    },
+    // reset list
+    async useReset() {
+      const { type, source, queryParams } = this.$props;
+      this.model = {
+        type,
+        search: "",
+        ...this.model,
+        ...queryParams(source),
+      };
+      await this.fetchList(this.model);
+    },
+    // query list
+    async useQuery() {
+      await this.fetchList(this.model);
+    },
+    // cancel
+    useCancel(prop) {
+      const { multiple } = this.$props;
+      this.useUpdate(multiple ? prop : prop[0]);
+      this.hide();
+    },
+    // confirm
+    useConfirm(prop) {
+      const { multiple } = this.$props;
+      this.useUpdate(multiple ? prop : prop[0]);
+      this.emitChange(this.selectData);
+      this.lastSelectData = deepCopy(this.selectData);
+      this.hide();
+    },
+    // delete tag
+    useDelete(prop) {
+      this.selectData.splice(prop, 1);
+      this.useUpdate(this.selectData);
+      this.emitChange(this.selectData);
+      this.lastSelectData = deepCopy(this.selectData);
+    },
+    // update
+    useUpdate(prop) {
+      const { source, multiple, valueKey, dataMapping, type } = this.$props;
+      // update data mapping
+      if (multiple) {
+        const vModel = prop.map((item) => item[valueKey]);
+        this.$emit("input", vModel);
+      } else {
+        const vModel = prop[valueKey];
+        this.$emit("input", vModel);
         for (let key in dataMapping) {
-          source[key] = prop[0][dataMapping[key]];
+          source[key] = prop[dataMapping[key]];
         }
         this.$emit("update:source", source);
       }
-      //
-      this.$emit("change", prop, source);
+    },
+    // click select row data
+    onceSelect(prop) {
+      if (prop) this.selectData = [prop];
+    },
+    // double click select row data and confirm
+    doubleSelect(prop) {
+      this.useConfirm([prop]);
+    },
+    // multiple select row data
+    selectionChange(prop, data) {
+      if (prop) {
+        this.selectData.push(data);
+      } else {
+        const { code } = data;
+        const index = this.selectData.findIndex((item) => item.code === code);
+        this.selectData.splice(index, 1);
+      }
     },
   },
-  created() {
-    this.$nextTick(() => {
-      const { clientWidth } = this.$refs.PopoverTreeSelect;
-      this.width = clientWidth;
-    });
-  },
+  created() {},
   mounted() {},
   destroyed() {},
 };
 </script>
 <template>
-  <div ref="PopoverTreeSelect" style="position: relative">
+  <div class="popover-tree-select">
     <el-input
-      v-model="showValue"
+      v-model="innerValue"
       :size="size"
       :disabled="disabled"
+      :readonly="readonly"
       :clearable="clearable"
       :placeholder="placeholder"
-      readonly
-      style="width: 100%; cursor: pointer"
-      @click.native.stop="handleAsyncOpenDialog"
     >
-      <template #suffix>
-        <el-icon class="el-icon-more"></el-icon>
-      </template>
+      <el-button
+        :disabled="disabled"
+        slot="append"
+        icon="el-icon-search"
+        @click="open"
+      ></el-button>
     </el-input>
+
+    <el-dialog
+      :title="`${title}(${multiple ? '多选' : '单选'})`"
+      :width="width"
+      :visible.sync="visible"
+      :close-on-click-modal="false"
+      :close-on-press-escape="false"
+      append-to-body
+      @close="hide"
+    >
+      <el-form
+        v-loading="loading"
+        :size="size"
+        :inline="true"
+        :model="params"
+        @submit.native.prevent
+      >
+        <el-form-item prop="search">
+          <el-input
+            v-model="params.search"
+            @keydown.enter="useQuery"
+            @change="useQuery"
+          >
+          </el-input>
+        </el-form-item>
+        <el-form-item>
+          <el-button icon="el-icon-refresh" @click="useReset"></el-button>
+        </el-form-item>
+      </el-form>
+      <el-tree
+        v-if="multiple"
+        :data="data"
+        :props="defaultProps"
+        accordion
+        node-key="id"
+      >
+        <div slot-scope="{ node, data }">
+          <el-checkbox
+            v-model="data.checked"
+            @click.native.stop
+            @change="selectionChange($event, data)"
+            style="margin: 0 5px 0 0"
+          >
+          </el-checkbox>
+          <span> {{ data.name }}</span>
+        </div>
+      </el-tree>
+      <el-radio-group v-else v-model="radio" style="width: 100%">
+        <el-tree
+          v-loading="loading"
+          :data="data"
+          :props="defaultProps"
+          accordion
+          node-key="id"
+        >
+          <div slot-scope="{ node, data }">
+            <el-radio
+              :label="data.code"
+              @click.native.stop="onceSelect(data)"
+              @dblclick.native.stop="doubleSelect(data)"
+              style="margin: 0 5px 0 0"
+            >
+              {{ data.name }}
+            </el-radio>
+          </div>
+        </el-tree>
+      </el-radio-group>
+      <div style="margin-top: 20px; text-align: right">
+        <el-button :size="size" @click="visible = false">取 消</el-button>
+        <el-button :size="size" type="primary" @click="useConfirm(selectData)"
+          >确 定</el-button
+        >
+      </div>
+    </el-dialog>
     <div
       style="
         position: absolute;
@@ -169,7 +310,7 @@ export default {
         overflow: hidden;
       "
     >
-      <div v-if="multiple && data.length">
+      <div v-if="multiple && selectData.length">
         <el-popover
           :offset="-10"
           :width="width"
@@ -180,10 +321,10 @@ export default {
           placement="bottom-start"
         >
           <el-tag slot="reference" :size="size" style="margin-right: 10px">
-            + {{ data.length }}
+            + {{ selectData.length }}
           </el-tag>
           <el-tag
-            v-for="(item, index) in data"
+            v-for="(tag, index) in selectData"
             :size="size"
             hit
             closable
@@ -191,23 +332,15 @@ export default {
               display: 'flex',
               justifyContent: 'space-between',
               alignItems: 'center',
-              margin: data.length - 1 === index ? '0' : '0 0 5px 0',
+              margin: selectData.length - 1 === index ? '0' : '0 0 5px 0',
             }"
-            @close="handleDelete(index)"
+            @close="useDelete(index)"
           >
-            {{ item.name }}
+            {{ tag.name }}
           </el-tag>
         </el-popover>
       </div>
     </div>
-    <table-dialog
-      ref="TableDialog"
-      :type="type"
-      :title="title"
-      :multiple="multiple"
-      :query-params="queryParams"
-      @confirm="handleAdd"
-    ></table-dialog>
   </div>
 </template>
 <style scoped></style>

+ 2 - 1
src/views/material/requisition/add.vue

@@ -1014,7 +1014,8 @@ export default {
         this.isStock = false
       } else {
         // 联动效期管理
-        this.basicForm.expiryDateManagerment = '2'
+        this.basicForm.expiryDateManagerment = '2';
+        this.basicForm.serialNoManager = '2';
         this.expCt(val)
         this.isStock = true
       }

+ 11 - 1
src/views/purchase/DemandSummary/add.vue

@@ -103,7 +103,7 @@
         <el-table-column show-overflow-tooltip label="处理确认时间" align="center" prop="affirmerTime" width="150"/>
         <!-- <el-table-column show-overflow-tooltip label="转请购时间" align="center" prop="code"/>
         <el-table-column show-overflow-tooltip label="转请购人员" align="center" prop="code"/> -->
-        <el-table-column show-overflow-tooltip label="价格类型" align="center" prop="priceType" width="150"/>
+        <el-table-column show-overflow-tooltip label="价格类型" align="center" prop="priceType" width="150" :formatter="priceClass"/>
       </el-table>
     </el-card>
 
@@ -126,6 +126,16 @@ export default {
   },
   data() {
     return{
+      priceClass(row) {
+        switch (row.priceType) {
+          case 'order':
+            return '订货价'
+          case 'consignment':
+            return '寄售价'
+          case 'adjusted':
+            return '调货价'
+        }
+      },
       // 不能直接改变props传来的值
       sonPageStu: this.pageStu,
       sonDisable: this.disable,

+ 14 - 2
src/views/purchase/DemandSummary/index.vue

@@ -285,6 +285,7 @@
           :key="isUpdate"
         >
           <el-table-column type="selection" width="60" />
+          <!-- <el-table-column show-overflow-tooltip label="行号" align="center" prop="rowNo"/> -->
           <el-table-column show-overflow-tooltip label="行状态" align="center" prop="status" width="120px" :formatter="hangStatus"/>
           <el-table-column show-overflow-tooltip label="一级品类" align="center" prop="materialClassifyOneName" width="120px"/>
           <el-table-column show-overflow-tooltip label="物料编码" align="center" prop="materialCode" width="180px"/>
@@ -346,8 +347,7 @@
           <el-table-column show-overflow-tooltip label="有效期单位" align="center" prop="validityPeriodUnit" width="100px"/>
           <el-table-column show-overflow-tooltip label="业务类型" align="center" prop="businessType" :formatter="formatterBusinessType"/>
           <el-table-column show-overflow-tooltip label="安全库存量" align="center" prop="safetyStock" width="100px"/>
-          <el-table-column show-overflow-tooltip label="单据来源" align="center" prop="billSource"/>
-          <el-table-column show-overflow-tooltip label="行号" align="center" prop="rowNo"/>
+          <el-table-column show-overflow-tooltip label="单据来源" align="center" prop="billSource" :formatter="formatterSource"/>
           <el-table-column show-overflow-tooltip label="注册人" align="center" prop="registrant"/>
           <!-- <el-table-column label="可用量" align="center" prop="qty"/> -->
           <el-table-column show-overflow-tooltip label="总需与终采差异" align="center" prop="buyDiscrepancy" width="120px"/>
@@ -445,6 +445,18 @@ export default {
             return '合作部门需求'
         }
       },
+      formatterSource(row) {
+        switch (row.billSource) {
+          case '1':
+            return '手工导入'
+          case '2':
+            return '按客户计算'
+          case '3':
+            return '按仓库计算'
+          case '4':
+            return '手工新增'
+        }
+      },
       isUpdate: false,
       expanded: false,
       // 页面配置

+ 12 - 1
src/views/purchase/PurchaseDemandList/add.vue

@@ -42,7 +42,7 @@
 
          <el-col :span="1.5">
             <el-form-item label="需求客户" prop="customer" :rules="{ required: true, message: '请选择需求客户', trigger: 'blur' }">
-              <el-select clearable size="small" v-model="basicForm.customer" :disabled="sonDisable" @focus="chooseOrg('CUSTOMER_PARAM', true, '选择客户')" style="width: 200px">
+              <el-select clearable size="small" v-model="basicForm.customer" :disabled="sonDisable" @clear="cleanCustomer" @focus="chooseOrg('CUSTOMER_PARAM', true, '选择客户')" style="width: 200px">
                 <el-option v-for="item in customerOptions" :key="item.id" :label="item.name" :value="item.id" />
               </el-select>
             </el-form-item>
@@ -1018,6 +1018,17 @@ export default {
         this.basicForm.puDemandItemList[index].additionalSupplier = null
       }
     },
+    // 清除需求客户将明细行内也清空
+    cleanCustomer() {
+      this.basicForm.customer = ''
+      this.basicForm.customerName = ''
+      if (this.basicForm.puDemandItemList.length !== 0) {
+        this.basicForm.puDemandItemList.forEach(item => {
+          item.demandCustomerName = ''
+          item.demandCustomer = ''
+        })
+      }
+    },
   }
 }
 </script>

+ 7 - 23
src/views/purchase/PurchaseDemandList/index.vue

@@ -94,30 +94,15 @@
             </el-form-item>
           </el-col>
           <el-col :span="1.5">
-            <el-form-item label="审批结束日期">
-              <el-date-picker
-                v-model="queryParams.approverFinishTime"
-                type="date"
-                clearable
-                value-format="yyyy-MM-dd"
+            <el-form-item label="备注">
+              <el-input
+                v-model.trim="queryParams.remark"
                 size="small"
+                clearable
                 style="width: 200px"
-              >
-              </el-date-picker>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="10">
-          <el-col :span="1.5">
-            <el-form-item label="备注">
-            <el-input
-              v-model.trim="queryParams.remark"
-              size="small"
-              clearable
-              style="width: 200px"
-            />
-            </el-form-item>
-          </el-col>
+              />
+              </el-form-item>
+            </el-col>
         </el-row>
         </div>
       </CollapseTransition>
@@ -283,7 +268,6 @@ export default {
         billType: '',
         demandDept: '',
         demandDate: '',
-        approverFinishTime: '',
         remark: '',
         pageNum: 1,
         pageSize: 5

+ 46 - 7
src/views/purchase/contract/add/index.vue

@@ -1,7 +1,12 @@
 <script>
 import { Columns, TabColumns } from "../column";
 import { REFER } from "@/components/popover-select/api";
-import { ADD, CODE } from "@/api/business/purchase/contract";
+import {
+  ADD,
+  CODE,
+  TABLEADD,
+  TABLEROMOVE,
+} from "@/api/business/purchase/contract";
 import { initDicts, initRules, initParams } from "@/utils/init";
 
 export default {
@@ -112,8 +117,37 @@ export default {
       this.params[prop].push(initParams(tab.tableColumns));
     },
     //
-    rowDelete(prop, index) {
-      prop.splice(index, 1);
+    async rowDelete(prop, { row: { id }, $index }) {
+      if (id) {
+        try {
+          this.loading = true;
+          const { code } = await TABLEROMOVE(id, prop);
+          if (code === 200) {
+            this.fetchTable(this.params.code, prop);
+          }
+        } catch (err) {
+          // catch
+        } finally {
+          // finally
+          this.loading = false;
+        }
+      } else {
+        this.params[prop].splice($index, 1);
+      }
+    },
+    //
+    async rowSubmit(prop, { row }) {
+      try {
+        this.loading = true;
+        const { code } = this.params;
+        await TABLEADD({ ...row, contractId: code }, prop);
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.loading = false;
+      }
     },
     //
     submit(prop) {
@@ -331,7 +365,7 @@ export default {
                   <span v-else> {{ scope.row[cColumn.key] }}</span>
                 </template>
               </el-table-column>
-              <el-table-column fixed="right" label="操作" width="75">
+              <el-table-column fixed="right" label="操作" width="100">
                 <template slot="header" slot-scope="scope">
                   <el-button
                     circle
@@ -344,11 +378,16 @@ export default {
                 <template slot-scope="scope">
                   <el-button
                     circle
+                    icon="el-icon-check"
+                    :size="size"
+                    @click.native.prevent="rowSubmit(tabName, scope)"
+                  >
+                  </el-button>
+                  <el-button
+                    circle
                     icon="el-icon-minus"
                     :size="size"
-                    @click.native.prevent="
-                      rowDelete(params[tabName], scope.$index)
-                    "
+                    @click.native.prevent="rowDelete(tabName, scope)"
                   >
                   </el-button>
                 </template>

+ 29 - 26
src/views/purchase/contract/edit/index.vue

@@ -53,22 +53,23 @@ export default {
           this.tabColumns = TabColumns;
         }
         this.tabName = this.tabColumns[0].key;
+        this.fetchTable(this.params.code, this.tabName);
       },
       immediate: true,
     },
-    "params.contractItemList": {
-      handler: function (newProp, oldProp) {
-        console.log(newProp, oldProp);
-        if (newProp.length === oldProp.length) {
-          const index = newProp.findIndex(
-            (item, index) =>
-              JSON.stringify(item) === JSON.stringify(oldProp[index])
-          );
-          console.log(index);
-        }
-      },
-      deep: true,
-    },
+    // "params.contractItemList": {
+    //   handler: function (newProp, oldProp) {
+    //     console.log(newProp, oldProp);
+    //     if (newProp.length === oldProp.length) {
+    //       const index = newProp.findIndex(
+    //         (item, index) =>
+    //           JSON.stringify(item) === JSON.stringify(oldProp[index])
+    //       );
+    //       console.log(index);
+    //     }
+    //   },
+    //   deep: true,
+    // },
   },
   methods: {
     //
@@ -89,8 +90,6 @@ export default {
         const { code, data } = await ITEM(prop);
         if (code === 200) {
           this.params = data;
-          this.tabName = this.tabColumns[0].key;
-          this.fetchTable(this.params.code, this.tabName);
         }
       } catch (err) {
         // catch
@@ -145,18 +144,22 @@ export default {
       this.params[prop].push(initParams(tab.tableColumns));
     },
     //
-    async rowDelete(prop, { row: { id } }) {
-      try {
-        this.loading = true;
-        const { code } = await TABLEROMOVE(id, prop);
-        if (code === 200) {
-          this.fetchTable(this.params.code, this.tabName);
+    async rowDelete(prop, { row: { id }, $index }) {
+      if (id) {
+        try {
+          this.loading = true;
+          const { code } = await TABLEROMOVE(id, prop);
+          if (code === 200) {
+            this.fetchTable(this.params.code, prop);
+          }
+        } catch (err) {
+          // catch
+        } finally {
+          // finally
+          this.loading = false;
         }
-      } catch (err) {
-        // catch
-      } finally {
-        // finally
-        this.loading = false;
+      } else {
+        this.params[prop].splice($index, 1);
       }
     },
     //

+ 4 - 7
src/views/purchase/task/column.js

@@ -1,5 +1,6 @@
 export const TableColumns = [
   { key: "code", title: "订单生成单号", width: 250 },
+  { key: "demandCode", title: "需求单号", width: 250 },
   { key: "materialCode", title: "物料编码" },
   { key: "materialName", title: "物料名称" },
   // { key: "material", title: "物料" },
@@ -7,10 +8,10 @@ export const TableColumns = [
   { key: "manufacturerName", title: "生产厂家" },
   { key: "puQty", title: "采购数量" },
   {
-    key: "priceinputType",
+    key: "priceType",
     title: "价格类型",
     inputType: "Select",
-    referName: "sys_price_inputType",
+    referName: "sys_price_type",
   },
   { key: "puUnitName", title: "采购单位" },
   // { key: "id", title: "主键" },
@@ -77,7 +78,6 @@ export const SearchColumns = [
     referName: "MATERIALCLASSIFY_PARAM",
     readonly: true,
     dataMapping: {},
-    queryParams: () => ({}),
   },
   {
     key: "materialCodes",
@@ -88,7 +88,6 @@ export const SearchColumns = [
     referName: "MATERIAL_PARAM",
     readonly: true,
     dataMapping: {},
-    queryParams: () => ({}),
   },
   { key: "materialDesc", title: "物料描述", inputType: "Input" },
   { key: "code", title: "单据号", inputType: "Input" },
@@ -101,7 +100,6 @@ export const SearchColumns = [
     referName: "ORG_PARAM",
     readonly: true,
     dataMapping: {},
-    queryParams: () => ({}),
   },
   {
     key: "status",
@@ -127,11 +125,10 @@ export const SearchColumns = [
     title: "采购员",
     inputType: "PopoverSelect",
     multiple: true,
-    valueKey: "id",
+    valueKey: "code",
     referName: "CONTACTS_PARAM",
     readonly: true,
     dataMapping: {},
-    queryParams: () => ({}),
   },
   {
     key: "documentsCodes",

+ 2 - 0
src/views/purchase/task/first-direct/column.js

@@ -12,6 +12,8 @@ export const TableColumns = [
   { key: "tax", title: "税率" },
   { key: "taxFreePrice", title: "无税单价" },
   { key: "taxPrice", title: "主含税单价" },
+  { key: "executeQty", title: "已执行数量" },
+  { key: "residueQty", title: "未执行数量" },
   {
     key: "purchaseQuantity",
     title: "本次采购数量",

+ 20 - 18
src/views/purchase/task/index.vue

@@ -36,15 +36,10 @@ export default {
     async fetchList(prop, page) {
       try {
         this.loading = true;
-        const { pageNum, pageSize } = page;
-        const { code,rows, total } = await LIST(
-          { ...prop },
-          { pageNum, pageSize }
-        );
+        const { code, rows, total } = await LIST(prop, page);
         if (code === 200) {
           this.tableData = rows;
           this.page.total = total;
-          
         } else {
           this.$notify.warning({ title: msg });
         }
@@ -57,6 +52,7 @@ export default {
     },
     // 查 询
     useQuery(prop, page) {
+      const { pageNum, pageSize } = page;
       const { date, documentsCodes } = prop;
       prop.endDate = date[1];
       prop.startDate = date[0];
@@ -64,13 +60,8 @@ export default {
         ? documentsCodes.split(",")
         : undefined;
       this.fetchList(
-        {
-          ...prop,
-          isAsc: "desc",
-          date: undefined,
-          orderByColumn: "createTime",
-        },
-        page
+        { ...prop, date: undefined },
+        { pageNum, pageSize, isAsc: "desc", orderByColumn: "createTime" }
       );
     },
     // 重 置
@@ -81,7 +72,16 @@ export default {
     },
     // 选 择
     useSelect(prop) {
-      this.selectData = prop;
+      if (prop && prop.length) {
+        // const lastIndex = prop.length - 1;
+        // const { status } = prop[lastIndex];
+        // if (status === "1") {
+        //   this.selectData.splice(lastIndex, 1);
+        // } else {
+        this.selectData = prop;
+        // }
+      }
+      console.log(this.selectData);
     },
     // 行 关
     async useClose(prop) {
@@ -159,6 +159,7 @@ export default {
               :clearable="column.clearable"
               :placeholder="column.placeholder"
               style="width: 100%"
+              @change="useQuery(params, page)"
               @keyup.enter.native="useQuery(params, page)"
             ></el-input>
             <el-select
@@ -168,6 +169,7 @@ export default {
               :clearable="column.clearable"
               :placeholder="column.placeholder"
               style="width: 100%"
+              @change="useQuery(params, page)"
               @keyup.enter.native="useQuery(params, page)"
             >
               <el-option
@@ -190,6 +192,7 @@ export default {
               :end-placeholder="column.endPlaceholder"
               :start-placeholder="column.startPlaceholder"
               style="width: 100%"
+              @change="useQuery(params, page)"
               @keyup.enter.native="useQuery(params, page)"
             >
             </el-date-picker>
@@ -204,8 +207,7 @@ export default {
               :readonly="column.readonly"
               :value-key="column.valueKey"
               :placeholder="column.placeholder"
-              :data-mapping="column.dataMapping"
-              :query-params="column.queryParams"
+              @change="useQuery(params, page)"
               @keyup.enter.native="useQuery(params, page)"
             >
             </dr-popover-select>
@@ -216,11 +218,11 @@ export default {
               :title="column.title"
               :type="column.referName"
               :multiple="column.multiple"
-              :show-key="column.showKey"
               :value-key="column.valueKey"
               :placeholder="column.placeholder"
-              :data-mapping="column.dataMapping"
               :query-params="column.queryParams"
+              @change="useQuery(params, page)"
+              @keyup.enter.native="useQuery(params, page)"
             >
             </dr-popover-tree-select>
           </el-form-item>

+ 13 - 3
src/views/purchase/transferOrder/add.vue

@@ -621,6 +621,7 @@ export default {
       sonDisable: this.disable,
       basicForm: {
         deliveryInventoryOrg: '',
+        deliveryInventoryOrgCode: '',
         deliveryInventoryOrgName: '',
         billType: '',
         code: '',
@@ -644,6 +645,7 @@ export default {
         customer: '',
         customerName: '',
         deliveryWarehouse: '',
+        deliveryWarehouseCode: '',
         deliveryWarehouseName: '',
         storageWarehouse: '',
         storageWarehouseName: '',
@@ -808,6 +810,9 @@ export default {
         if (type == 'WAREHOUSE_PARAM' && title == '调出仓库') {
           this.chuHouseOptions = res.rows
         }
+        if (type == 'UNIT_PARAM') {
+          this.materialInfo[this.tableIndex].unitCode = res.rows[0].code
+        }
       })
     },
     addLine() {
@@ -823,6 +828,7 @@ export default {
         originPlaceName: null,
         model: null,
         unit: null,
+        unitCode: null,
         unitName: null,
         deliveryWarehouseName: null,
         qty: null,
@@ -875,6 +881,7 @@ export default {
       if (this.referCondition.title == '调出库存组织') {
         this.chuOrgOptions = selection
         this.basicForm.deliveryInventoryOrg = selection[0].id
+        this.basicForm.deliveryInventoryOrgCode = selection[0].code
         this.basicForm.deliveryInventoryOrgName = selection[0].name
       }
       if (this.referCondition.title == '调入库存组织') {
@@ -913,6 +920,7 @@ export default {
       if (this.referCondition.title == '调出仓库') {
         this.chuHouseOptions = selection
         this.basicForm.deliveryWarehouse = selection[0].id
+        this.basicForm.deliveryWarehouseCode = selection[0].code
         this.basicForm.deliveryWarehouseName = selection[0].name
       }
       if (this.referCondition.title == '调出货位') {
@@ -960,14 +968,16 @@ export default {
       this.materialInfo[this.tableIndex].manufacturer = selection[0].manufacturerIdName
       this.materialInfo[this.tableIndex].marketingApprovalPersonal = selection[0].registrant
       this.materialInfo[this.tableIndex].production = selection[0].productionPermit
+      // 根据物料单位id查询单位code
+      this.reBackRefer('UNIT_PARAM', selection[0].unitId)
     },
     // 明细行选择批次号
     chooseBatch(index) {
       this.tableIndex = index
-      this.referConditionMx.orgCode = this.basicForm.deliveryInventoryOrg
+      this.referConditionMx.orgCode = this.basicForm.deliveryInventoryOrgCode
       this.referConditionMx.materialCode = this.materialInfo[this.tableIndex].material
-      this.referConditionMx.unitCode = this.materialInfo[this.tableIndex].unit
-      this.referConditionMx.warehouseCode = this.basicForm.deliveryWarehouse
+      this.referConditionMx.unitCode = this.materialInfo[this.tableIndex].unitCode
+      this.referConditionMx.warehouseCode = this.basicForm.deliveryWarehouseCode
       this.$refs.batchRefer.init(this.referConditionMx)
     },
     selectBatch(selection) {