002201 2 years ago
parent
commit
9182420330

+ 14 - 0
src/api/business/purchase/purchase-contract.js

@@ -15,3 +15,17 @@ export function add(data) {
     data: data,
   });
 }
+
+export function remove(data) {
+  return request({
+    url: `/pu/contract/${data}`,
+    method: "delete",
+  });
+}
+
+export function item(data) {
+  return request({
+    url: `/pu/contract/${data}`,
+    method: "get",
+  });
+}

+ 0 - 34
src/utils/init-something.js

@@ -1,34 +0,0 @@
-import { arr2obj } from "./data-transform";
-import Components from "@/views/common-dialog";
-
-export const initParams = (arr) => arr2obj(arr, "key", "value");
-
-export const initDicts = (arr) =>
-  arr
-    .filter((column) => column.type === "Select")
-    .map((column) => column.config.optionsName);
-
-export const initRules = (arr) => {
-  const rules = {};
-  arr
-    .filter((column) => column.require)
-    .forEach((column) => {
-      const message = `${column.title}不能为空`;
-      rules[column.key] = [
-        { required: true, message: message, trigger: "change" },
-      ];
-    });
-  return rules;
-};
-
-export const initComponents = (arr) => {
-  const c = {};
-  arr
-    .filter((element) => element.type === "InputDialog")
-    .map((element) => element.config.componentName)
-    .forEach((element) => {
-      c[element] = Components[element];
-    });
-
-  return c;
-};

+ 77 - 0
src/utils/init/index.js

@@ -0,0 +1,77 @@
+import { arr2obj } from "../data-transform";
+
+export const initColumns = (
+  arr,
+  prop = { disabled: false, readonly: false, clearable: false }
+) => {
+  return arr
+    .map((element) => {
+      let config = element.config || {};
+      const type = element.type;
+      if (type === "Input") {
+      }
+      if (type === "InputDialog") {
+        prop.readonly = true;
+      }
+      if (type === "InputNumber") {
+        config = { controlsPosition: "right", ...config };
+      }
+      if (type === "Select") {
+      }
+      if (type === "DatePicker") {
+        config = { type: "date", ...config };
+      }
+      return { config, ...element, ...prop };
+    })
+    .map((element) => {
+      let value = "";
+      if (element.type === "DatePicker") value = new Date();
+      else if (element.type === "InputNumber") value = 1;
+      else value = "1";
+      return { ...element, value };
+    });
+};
+
+// 初始化参数
+export const initParams = (prop, key = "key", value = "value") =>
+  arr2obj(prop, key, value);
+// 初始化字典
+export const initDicts = (prop) =>
+  prop
+    .filter((column) => column.type === "Select")
+    .map((column) => column.config.optionsName);
+// 初始化校验
+export const initRules = (prop) => {
+  const rules = {};
+  prop
+    .filter((column) => column.require)
+    .forEach((column) => {
+      const message = `${column.title}不能为空`;
+      rules[column.key] = [
+        { required: true, message: message, trigger: "change" },
+      ];
+    });
+  return rules;
+};
+
+const pageSizes = [25, 50, 100];
+
+const layout = "total, prev, pager, next, sizes, jumper";
+
+const page = { pageNum: 1, pageSize: 25, total: 0 };
+
+export const initPageSizes = () => pageSizes;
+
+export const initLayout = () => layout;
+
+export const initPage = () => page;
+
+// export default function InitHooks(prop) {
+//   return {
+//     initPage,
+//     initParams,
+//     initDicts: initDicts(prop),
+//     initRules: initRules(prop),
+//     initComponents: initComponents(prop),
+//   };
+// }

+ 11 - 0
src/utils/init/page.js

@@ -0,0 +1,11 @@
+const pageSizes = [25, 50, 100];
+
+const layout = "total, prev, pager, next, sizes, jumper";
+
+const page = { pageNum: 1, pageSize: 25, total: 0 };
+
+export const initPageSizes = () => pageSizes;
+
+export const initLayout = () => layout;
+
+export const initPage = () => page;

+ 0 - 214
src/views/common-dialog/currency.vue

@@ -1,214 +0,0 @@
-<script>
-import { initParams } from "./utils/init-something";
-import { list } from "./api/index";
-
-export default {
-  name: "CurrencyInputDialog",
-  props: ["title", "value"],
-  components: {},
-  data() {
-    const columns = [
-      {
-        key: "name",
-        title: "币种",
-        type: "Input",
-        search: true,
-      },
-      {
-        key: "code",
-        title: "币种简称",
-        type: "Input",
-        search: true,
-      },
-      {
-        key: "",
-        title: "单价精度",
-      },
-      {
-        key: "",
-        title: "单价舍入规则",
-      },
-      {
-        key: "",
-        title: "金额精度",
-      },
-      {
-        key: "",
-        title: "金额舍入规则",
-      },
-    ];
-    const initTableColumns = () => columns.filter((column) => column.key);
-    const initSearchColumns = () => columns.filter((column) => column.search);
-    return {
-      // global
-      size: "mini",
-      width: "50%",
-      page: { pageNum: 1, pageSize: 25, total: 0 },
-      pageSizes: [25, 50],
-      layout: "prev, pager, next, jumper",
-      api: "puCurrType",
-      showKey: "name",
-      // dialog
-      visible: false,
-      loading: false,
-      // search
-      searchColumns: initSearchColumns(),
-      params: initParams(initSearchColumns()),
-      // table
-      tableColumns: initTableColumns(),
-      data: [],
-      currentData: null,
-    };
-  },
-  computed: {},
-  watch: {},
-  methods: {
-    // set dialog visible
-    setVisible(prop) {
-      this.visible = prop;
-    },
-    // do something before dialog open
-    beforeOpen() {
-      const { value } = this.$props;
-      this.params[this.showKey] = value;
-      this.fetchList(this.params, this.page);
-    },
-    // fetch table data
-    async fetchList(prop, page) {
-      try {
-        this.loading = true;
-        const { pageNum, pageSize } = page;
-        const { code, msg, rows, total } = await list(this.api, {
-          ...prop,
-          pageNum,
-          pageSize,
-        });
-        if (code === 200) {
-          this.data = rows;
-          this.page.total = total;
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
-        }
-      } catch (err) {
-        this.$notify.error({ title: "error", message: err });
-      } finally {
-        this.loading = false;
-        this.setCurrentData(
-          this.data.find(
-            (column) => column[this.showKey] === this.currentData[this.showKey]
-          )
-        );
-      }
-    },
-    // setting up to fetch table data
-    queryList() {
-      this.fetchList(this.params, this.page);
-    },
-    // reset to fetch table data
-    resetList() {
-      this.page.pageNum = 1;
-      this.params = initParams(this.searchColumns);
-      this.fetchList(this.params, this.page);
-    },
-    // size change to fetch table data
-    pageSizeChange(prop) {
-      this.page.pageSize = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // number change to fetch table data
-    pageNumberChange(prop) {
-      this.page.pageNum = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // select row data
-    selectCurrentData(row) {
-      this.currentData = row;
-    },
-    // set row data highlight
-    setCurrentData(row) {
-      this.$refs.singleTable.setCurrentRow(row);
-    },
-    //
-    confirm() {
-      if (this.currentData) {
-        this.$emit("confirm", this.currentData);
-      }
-      this.setVisible(false);
-    },
-  },
-  created() {},
-  mounted() {},
-  destroyed() {},
-};
-</script>
-<template>
-  <el-dialog
-    :title="title"
-    :visible.sync="visible"
-    :width="width"
-    append-to-body
-    @open="beforeOpen"
-  >
-    <el-form :size="size" :inline="true" :model="params">
-      <el-form-item
-        v-for="(column, index) in searchColumns"
-        :key="index"
-        :label="column.title"
-      >
-        <el-input v-model="params[column.key]" @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-table
-      v-loading="loading"
-      :data="data"
-      :size="size"
-      ref="singleTable"
-      height="45vh"
-      highlight-current-row
-      style="width: 100%; margin-bottom: 20px"
-      @row-click="selectCurrentData"
-    >
-      <el-table-column
-        v-for="(column, index) in tableColumns"
-        :key="index"
-        :prop="column.key"
-        :label="column.title"
-        :width="column.width"
-        show-overflow-tooltip
-      >
-      </el-table-column>
-    </el-table>
-    <div
-      style="display: flex; justify-content: space-between; align-items: center"
-    >
-      <p>
-        <span style="font-size: 12px">已选择 :</span>
-        <el-tag v-if="currentData" :size="size">{{
-          currentData[showKey]
-        }}</el-tag>
-        <span v-else>无</span>
-      </p>
-      <el-pagination
-        :layout="layout"
-        :total="page.total"
-        :page-sizes="pageSizes"
-        :page-size="page.pageSize"
-        :current-page="page.pageNum"
-        :small="size === 'mini'"
-        background
-        @size-change="pageSizeChange"
-        @current-change="pageNumberChange"
-      >
-      </el-pagination>
-    </div>
-    <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">确 定</el-button>
-    </div>
-  </el-dialog>
-</template>
-<style scoped></style>

+ 0 - 198
src/views/common-dialog/department.vue

@@ -1,198 +0,0 @@
-<script>
-import { initParams } from "./utils/init-something";
-import { list } from "./api/index";
-
-export default {
-  name: "DepartmentInputDialog",
-  props: ["title", "value"],
-  components: {},
-  data() {
-    const columns = [
-      {
-        key: "deptId",
-        title: "组织编码",
-        type: "Input",
-        search: true,
-      },
-      {
-        key: "deptName",
-        title: "组织名称",
-        type: "Input",
-        search: true,
-      },
-    ];
-    const initTableColumns = () => columns.filter((column) => column.key);
-    const initSearchColumns = () => columns.filter((column) => column.search);
-    return {
-      // global
-      size: "mini",
-      width: "50%",
-      page: { pageNum: 1, pageSize: 25, total: 0 },
-      pageSizes: [25, 50],
-      layout: "prev, pager, next, jumper",
-      api: "puDept",
-      showKey: "deptName",
-      // dialog
-      visible: false,
-      loading: false,
-      // search
-      searchColumns: initSearchColumns(),
-      params: initParams(initSearchColumns()),
-      // table
-      tableColumns: initTableColumns(),
-      data: [],
-      currentData: null,
-    };
-  },
-  computed: {},
-  watch: {},
-  methods: {
-    // set dialog visible
-    setVisible(prop) {
-      this.visible = prop;
-    },
-    // do something before dialog open
-    beforeOpen() {
-      const { value } = this.$props;
-      this.params[this.showKey] = value;
-      this.fetchList(this.params, this.page);
-    },
-    // fetch table data
-    async fetchList(prop, page) {
-      try {
-        this.loading = true;
-        const { pageNum, pageSize } = page;
-        const { code, msg, rows, total } = await list(this.api, {
-          ...prop,
-          pageNum,
-          pageSize,
-        });
-        if (code === 200) {
-          this.data = rows;
-          this.page.total = total;
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
-        }
-      } catch (err) {
-        this.$notify.error({ title: "error", message: err });
-      } finally {
-        this.loading = false;
-        this.setCurrentData(
-          this.data.find(
-            (column) => column[this.showKey] === this.currentData[this.showKey]
-          )
-        );
-      }
-    },
-    // setting up to fetch table data
-    queryList() {
-      this.fetchList(this.params, this.page);
-    },
-    // reset to fetch table data
-    resetList() {
-      this.page.pageNum = 1;
-      this.params = initParams(this.searchColumns);
-      this.fetchList(this.params, this.page);
-    },
-    // size change to fetch table data
-    pageSizeChange(prop) {
-      this.page.pageSize = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // number change to fetch table data
-    pageNumberChange(prop) {
-      this.page.pageNum = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // select row data
-    selectCurrentData(row) {
-      this.currentData = row;
-    },
-    // set row data highlight
-    setCurrentData(row) {
-      this.$refs.singleTable.setCurrentRow(row);
-    },
-    //
-    confirm() {
-      if (this.currentData) {
-        this.$emit("confirm", this.currentData);
-      }
-      this.setVisible(false);
-    },
-  },
-  created() {},
-  mounted() {},
-  destroyed() {},
-};
-</script>
-<template>
-  <el-dialog
-    :title="title"
-    :visible.sync="visible"
-    :width="width"
-    append-to-body
-    @open="beforeOpen"
-  >
-    <el-form :size="size" :inline="true" :model="params">
-      <el-form-item
-        v-for="(column, index) in searchColumns"
-        :key="index"
-        :label="column.title"
-      >
-        <el-input v-model="params[column.key]" @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-table
-      v-loading="loading"
-      :data="data"
-      :size="size"
-      ref="singleTable"
-      height="45vh"
-      highlight-current-row
-      style="width: 100%; margin-bottom: 20px"
-      @row-click="selectCurrentData"
-    >
-      <el-table-column
-        v-for="(column, index) in tableColumns"
-        :key="index"
-        :prop="column.key"
-        :label="column.title"
-        :width="column.width"
-        show-overflow-tooltip
-      >
-      </el-table-column>
-    </el-table>
-    <div
-      style="display: flex; justify-content: space-between; align-items: center"
-    >
-      <p>
-        <span style="font-size: 12px">已选择 :</span>
-        <el-tag v-if="currentData" :size="size">{{
-          currentData[showKey]
-        }}</el-tag>
-        <span v-else>无</span>
-      </p>
-      <el-pagination
-        :layout="layout"
-        :total="page.total"
-        :page-sizes="pageSizes"
-        :page-size="page.pageSize"
-        :current-page="page.pageNum"
-        :small="size === 'mini'"
-        background
-        @size-change="pageSizeChange"
-        @current-change="pageNumberChange"
-      >
-      </el-pagination>
-    </div>
-    <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">确 定</el-button>
-    </div>
-  </el-dialog>
-</template>
-<style scoped></style>

+ 0 - 20
src/views/common-dialog/index.js

@@ -1,20 +0,0 @@
-// 员工
-import user from "./user.vue";
-// 组织
-import organization from "./organization.vue";
-// 部门
-import department from "./department.vue";
-// 供应商
-import supplier from "./supplier.vue";
-// 税率
-import tax from "./tax.vue";
-// 币种
-import currency from "./currency.vue";
-
-export const User = user;
-export const Organization = organization;
-export const Department = department;
-export const Supplier = supplier;
-export const Tax = tax;
-export const Currency = currency;
-export default { Tax, User, Supplier, Currency, Department, Organization };

+ 0 - 204
src/views/common-dialog/organization.vue

@@ -1,204 +0,0 @@
-<script>
-import { list, refer } from "./api/index";
-import { initParams } from "@/utils/init-something";
-
-export default {
-  name: "OrganizationInputDialog",
-  props: ["title", "value"],
-  components: {},
-  data() {
-    const columns = [
-      {
-        key: "deptId",
-        title: "组织编码",
-        type: "Input",
-        search: true,
-      },
-      {
-        key: "deptName",
-        title: "组织名称",
-        type: "Input",
-        search: true,
-      },
-    ];
-    const initTableColumns = () => columns.filter((column) => column.key);
-    const initSearchColumns = () => columns.filter((column) => column.search);
-    return {
-      // global
-      size: "mini",
-      width: "50%",
-      page: { pageNum: 1, pageSize: 25, total: 0 },
-      pageSizes: [25, 50],
-      layout: "prev, pager, next, jumper",
-      api: "puOrg",
-      showKey: "deptName",
-      // dialog
-      visible: false,
-      loading: false,
-      // search
-      searchColumns: initSearchColumns(),
-      params: initParams(initSearchColumns()),
-      // table
-      tableColumns: initTableColumns(),
-      data: [],
-      currentData: null,
-    };
-  },
-  computed: {},
-  watch: {},
-  methods: {
-    // set dialog visible
-    setVisible(prop) {
-      this.visible = prop;
-    },
-    // do something before dialog open
-    beforeOpen() {
-      const { value } = this.$props;
-      this.params[this.showKey] = value;
-      this.fetchList(this.params, this.page);
-    },
-    // fetch table data
-    async fetchList(prop, page) {
-      try {
-        this.loading = true;
-        const { pageNum, pageSize } = page;
-        // const { code, msg, rows, total } = await refer({
-        //   pageNum,
-        //   pageSize,
-        //   isPage: true,
-        //   type: "ORG_PARAM",
-        // });
-        const { code, msg, rows, total } = await list(this.api, {
-          ...prop,
-          pageNum,
-          pageSize,
-        });
-        if (code === 200) {
-          this.data = rows;
-          this.page.total = total;
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
-        }
-      } catch (err) {
-        this.$notify.error({ title: "error", message: err });
-      } finally {
-        this.loading = false;
-        this.setCurrentData(
-          this.data.find(
-            (column) => column[this.showKey] === this.currentData[this.showKey]
-          )
-        );
-      }
-    },
-    // setting up to fetch table data
-    queryList() {
-      this.fetchList(this.params, this.page);
-    },
-    // reset to fetch table data
-    resetList() {
-      this.page.pageNum = 1;
-      this.params = initParams(this.searchColumns);
-      this.fetchList(this.params, this.page);
-    },
-    // size change to fetch table data
-    pageSizeChange(prop) {
-      this.page.pageSize = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // number change to fetch table data
-    pageNumberChange(prop) {
-      this.page.pageNum = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // select row data
-    selectCurrentData(row) {
-      this.currentData = row;
-    },
-    // set row data highlight
-    setCurrentData(row) {
-      this.$refs.singleTable.setCurrentRow(row);
-    },
-    //
-    confirm() {
-      if (this.currentData) {
-        this.$emit("confirm", this.currentData);
-      }
-      this.setVisible(false);
-    },
-  },
-  created() {},
-  mounted() {},
-  destroyed() {},
-};
-</script>
-<template>
-  <el-dialog
-    :title="title"
-    :visible.sync="visible"
-    :width="width"
-    append-to-body
-    @open="beforeOpen"
-  >
-    <el-form :size="size" :inline="true" :model="params">
-      <el-form-item
-        v-for="(column, index) in searchColumns"
-        :key="index"
-        :label="column.title"
-      >
-        <el-input v-model="params[column.key]" @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-table
-      v-loading="loading"
-      :data="data"
-      :size="size"
-      ref="singleTable"
-      height="45vh"
-      highlight-current-row
-      style="width: 100%; margin-bottom: 20px"
-      @row-click="selectCurrentData"
-    >
-      <el-table-column
-        v-for="(column, index) in tableColumns"
-        :key="index"
-        :prop="column.key"
-        :label="column.title"
-        :width="column.width"
-        show-overflow-tooltip
-      >
-      </el-table-column>
-    </el-table>
-    <div
-      style="display: flex; justify-content: space-between; align-items: center"
-    >
-      <p>
-        <span style="font-size: 12px">已选择 :</span>
-        <el-tag v-if="currentData" :size="size">{{
-          currentData[showKey]
-        }}</el-tag>
-        <span v-else>无</span>
-      </p>
-      <el-pagination
-        :layout="layout"
-        :total="page.total"
-        :page-sizes="pageSizes"
-        :page-size="page.pageSize"
-        :current-page="page.pageNum"
-        :small="size === 'mini'"
-        background
-        @size-change="pageSizeChange"
-        @current-change="pageNumberChange"
-      >
-      </el-pagination>
-    </div>
-    <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">确 定</el-button>
-    </div>
-  </el-dialog>
-</template>
-<style scoped></style>

+ 0 - 203
src/views/common-dialog/payment-plan.vue

@@ -1,203 +0,0 @@
-<script>
-import { initParams } from "./utils/init-something";
-import { list } from "./api/index";
-
-export default {
-  name: "PaymentPlanInputDialog",
-  props: ["title", "value"],
-  components: {},
-  data() {
-    const columns = [
-      {
-        key: "",
-        title: "付款协议名称",
-        type: "Input",
-        search: true,
-      },
-      {
-        key: "",
-        title: "付款协议编码",
-        type: "Input",
-        search: true,
-      },
-      {
-        key: "",
-        title: "管理组织",
-      },
-      {
-        key: "",
-        title: "有效期开始时间",
-      },
-      {
-        key: "",
-        title: "有效期结束时间",
-      },
-      {
-        key: "",
-        title: "说明",
-      },
-    ];
-    const initTableColumns = () => columns.filter((column) => column.key);
-    const initSearchColumns = () => columns.filter((column) => column.search);
-    return {
-      // global
-      size: "mini",
-      width: "50%",
-      page: { pageNum: 1, pageSize: 25, total: 0 },
-      pageSizes: [25, 50],
-      layout: "prev, pager, next, jumper",
-      api: "puTaxRate",
-      showKey: "mattaxesname",
-      // dialog
-      visible: false,
-      loading: false,
-      // search
-      searchColumns: initSearchColumns(),
-      params: initParams(initSearchColumns()),
-      // table
-      tableColumns: initTableColumns(),
-      data: [],
-      currentData: null,
-    };
-  },
-  computed: {},
-  watch: {},
-  methods: {
-    // set dialog visible
-    setVisible(prop) {
-      this.visible = prop;
-    },
-    // do something before dialog open
-    beforeOpen() {
-      const { value } = this.$props;
-      this.params.deptName = value;
-      this.fetchList(this.params, this.page);
-    },
-    // fetch table data
-    async fetchList(prop, page) {
-      try {
-        this.loading = true;
-        const { pageNum, pageSize } = page;
-        const { code, msg, rows, total } = await list(this.api, {
-          ...prop,
-          pageNum,
-          pageSize,
-        });
-        if (code === 200) {
-          this.data = rows;
-          this.page.total = total;
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
-        }
-      } catch (err) {
-        this.$notify.error({ title: "error", message: err });
-      } finally {
-        this.loading = false;
-      }
-    },
-    // setting up to fetch table data
-    queryList() {
-      this.fetchList(this.params, this.page);
-    },
-    // reset to fetch table data
-    resetList() {
-      this.page.pageNum = 1;
-      this.params = initParams(this.searchColumns);
-      this.fetchList(this.params, this.page);
-    },
-    // size change to fetch table data
-    pageSizeChange(prop) {
-      this.page.pageSize = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // number change to fetch table data
-    pageNumberChange(prop) {
-      this.page.pageNum = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // select row data
-    selectCurrentData(row) {
-      this.currentData = row;
-    },
-    //
-    confirm() {
-      if (this.currentData) {
-        this.$emit("confirm", this.currentData);
-      }
-      this.setVisible(false);
-    },
-  },
-  created() {},
-  mounted() {},
-  destroyed() {},
-};
-</script>
-<template>
-  <el-dialog
-    :title="title"
-    :visible.sync="visible"
-    :width="width"
-    append-to-body
-    @open="beforeOpen"
-  >
-    <el-form :size="size" :inline="true" :model="params">
-      <el-form-item
-        v-for="(column, index) in searchColumns"
-        :key="index"
-        :label="column.title"
-      >
-        <el-input v-model="params[column.key]" @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-table
-      v-loading="loading"
-      :data="data"
-      :size="size"
-      height="45vh"
-      style="width: 100%; margin-bottom: 20px"
-      @row-click="selectCurrentData"
-    >
-      <el-table-column
-        v-for="(column, index) in tableColumns"
-        :key="index"
-        :prop="column.key"
-        :label="column.title"
-        :width="column.width"
-        show-overflow-tooltip
-      >
-      </el-table-column>
-    </el-table>
-    <div
-      style="display: flex; justify-content: space-between; align-items: center"
-    >
-      <p>
-        <span style="font-size: 12px">已选择 :</span>
-        <el-tag v-if="currentData" :size="size">{{
-          currentData[showKey]
-        }}</el-tag>
-        <span v-else>无</span>
-      </p>
-      <el-pagination
-        :layout="layout"
-        :total="page.total"
-        :page-sizes="pageSizes"
-        :page-size="page.pageSize"
-        :current-page="page.pageNum"
-        :small="size === 'mini'"
-        background
-        @size-change="pageSizeChange"
-        @current-change="pageNumberChange"
-      >
-      </el-pagination>
-    </div>
-    <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">确 定</el-button>
-    </div>
-  </el-dialog>
-</template>
-<style scoped></style>

+ 0 - 198
src/views/common-dialog/tax.vue

@@ -1,198 +0,0 @@
-<script>
-import { initParams } from "./utils/init-something";
-import { list } from "./api/index";
-
-export default {
-  name: "TaxInputDialog",
-  props: ["title", "value"],
-  components: {},
-  data() {
-    const columns = [
-      {
-        key: "mattaxesname",
-        title: "税目税率名称",
-        type: "Input",
-        search: true,
-      },
-      {
-        key: "mattaxescode",
-        title: "税目税率编码",
-        type: "Input",
-        search: true,
-      },
-    ];
-    const initTableColumns = () => columns.filter((column) => column.key);
-    const initSearchColumns = () => columns.filter((column) => column.search);
-    return {
-      // global
-      size: "mini",
-      width: "50%",
-      page: { pageNum: 1, pageSize: 25, total: 0 },
-      pageSizes: [25, 50],
-      layout: "prev, pager, next, jumper",
-      api: "puTaxRate",
-      showKey: "mattaxesname",
-      // dialog
-      visible: false,
-      loading: false,
-      // search
-      searchColumns: initSearchColumns(),
-      params: initParams(initSearchColumns()),
-      // table
-      tableColumns: initTableColumns(),
-      data: [],
-      currentData: null,
-    };
-  },
-  computed: {},
-  watch: {},
-  methods: {
-    // set dialog visible
-    setVisible(prop) {
-      this.visible = prop;
-    },
-    // do something before dialog open
-    beforeOpen() {
-      const { value } = this.$props;
-      this.params[this.showKey] = value;
-      this.fetchList(this.params, this.page);
-    },
-    // fetch table data
-    async fetchList(prop, page) {
-      try {
-        this.loading = true;
-        const { pageNum, pageSize } = page;
-        const { code, msg, rows, total } = await list(this.api, {
-          ...prop,
-          pageNum,
-          pageSize,
-        });
-        if (code === 200) {
-          this.data = rows;
-          this.page.total = total;
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
-        }
-      } catch (err) {
-        this.$notify.error({ title: "error", message: err });
-      } finally {
-        this.loading = false;
-        this.setCurrentData(
-          this.data.find(
-            (column) => column[this.showKey] === this.currentData[this.showKey]
-          )
-        );
-      }
-    },
-    // setting up to fetch table data
-    queryList() {
-      this.fetchList(this.params, this.page);
-    },
-    // reset to fetch table data
-    resetList() {
-      this.page.pageNum = 1;
-      this.params = initParams(this.searchColumns);
-      this.fetchList(this.params, this.page);
-    },
-    // size change to fetch table data
-    pageSizeChange(prop) {
-      this.page.pageSize = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // number change to fetch table data
-    pageNumberChange(prop) {
-      this.page.pageNum = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // select row data
-    selectCurrentData(row) {
-      this.currentData = row;
-    },
-    // set row data highlight
-    setCurrentData(row) {
-      this.$refs.singleTable.setCurrentRow(row);
-    },
-    //
-    confirm() {
-      if (this.currentData) {
-        this.$emit("confirm", this.currentData);
-      }
-      this.setVisible(false);
-    },
-  },
-  created() {},
-  mounted() {},
-  destroyed() {},
-};
-</script>
-<template>
-  <el-dialog
-    :title="title"
-    :visible.sync="visible"
-    :width="width"
-    append-to-body
-    @open="beforeOpen"
-  >
-    <el-form :size="size" :inline="true" :model="params">
-      <el-form-item
-        v-for="(column, index) in searchColumns"
-        :key="index"
-        :label="column.title"
-      >
-        <el-input v-model="params[column.key]" @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-table
-      v-loading="loading"
-      :data="data"
-      :size="size"
-      ref="singleTable"
-      height="45vh"
-      highlight-current-row
-      style="width: 100%; margin-bottom: 20px"
-      @row-click="selectCurrentData"
-    >
-      <el-table-column
-        v-for="(column, index) in tableColumns"
-        :key="index"
-        :prop="column.key"
-        :label="column.title"
-        :width="column.width"
-        show-overflow-tooltip
-      >
-      </el-table-column>
-    </el-table>
-    <div
-      style="display: flex; justify-content: space-between; align-items: center"
-    >
-      <p>
-        <span style="font-size: 12px">已选择 :</span>
-        <el-tag v-if="currentData" :size="size">{{
-          currentData[showKey]
-        }}</el-tag>
-        <span v-else>无</span>
-      </p>
-      <el-pagination
-        :layout="layout"
-        :total="page.total"
-        :page-sizes="pageSizes"
-        :page-size="page.pageSize"
-        :current-page="page.pageNum"
-        :small="size === 'mini'"
-        background
-        @size-change="pageSizeChange"
-        @current-change="pageNumberChange"
-      >
-      </el-pagination>
-    </div>
-    <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">确 定</el-button>
-    </div>
-  </el-dialog>
-</template>
-<style scoped></style>

+ 0 - 226
src/views/common-dialog/user.vue

@@ -1,226 +0,0 @@
-<script>
-import { initParams } from "./utils/init-something";
-import { list } from "./api/index";
-
-export default {
-  name: "UserInputDialog",
-  props: ["title"],
-  components: {},
-  data() {
-    const columns = [
-      {
-        key: "userName",
-        title: "员工姓名",
-        type: "Input",
-        search: true,
-      },
-      {
-        key: "userId",
-        title: "员工编码",
-        type: "Input",
-        search: true,
-      },
-      {
-        key: "orgName",
-        title: "任职(兼职)组织",
-        type: "Input",
-        width: 200,
-      },
-      {
-        key: "deptName",
-        title: "部门",
-        type: "Input",
-        width: 200,
-      },
-      {
-        key: "",
-        title: "岗位",
-        type: "Input",
-      },
-      {
-        key: "email",
-        title: "邮箱",
-        type: "Input",
-        width: 200,
-      },
-      {
-        key: "",
-        title: "职位",
-        type: "Input",
-      },
-    ];
-    const initTableColumns = () => columns.filter((column) => column.key);
-    const initSearchColumns = () => columns.filter((column) => column.search);
-    return {
-      // global
-      size: "mini",
-      width: "50%",
-      page: { pageNum: 1, pageSize: 25, total: 0 },
-      pageSizes: [25, 50],
-      layout: "prev, pager, next, jumper",
-      api: "puPersonnel",
-      showKey: "userName",
-      // dialog
-      visible: false,
-      loading: false,
-      // search
-      searchColumns: initSearchColumns(),
-      params: initParams(initSearchColumns()),
-      // table
-      tableColumns: initTableColumns(),
-      data: [],
-      currentData: null,
-    };
-  },
-  computed: {},
-  watch: {},
-  methods: {
-    // set dialog visible
-    setVisible(prop) {
-      this.visible = prop;
-    },
-    // do something before dialog open
-    beforeOpen() {
-      const { value } = this.$props;
-      this.params[this.showKey] = value;
-      this.fetchList(this.params, this.page);
-    },
-    // fetch table data
-    async fetchList(prop, page) {
-      try {
-        this.loading = true;
-        const { pageNum, pageSize } = page;
-        const { code, msg, rows, total } = await list(this.api, {
-          ...prop,
-          pageNum,
-          pageSize,
-        });
-        if (code === 200) {
-          this.data = rows;
-          this.page.total = total;
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
-        }
-      } catch (err) {
-        this.$notify.error({ title: "error", message: err });
-      } finally {
-        this.loading = false;
-        this.setCurrentData(
-          this.data.find(
-            (column) => column[this.showKey] === this.currentData[this.showKey]
-          )
-        );
-      }
-    },
-    // setting up to fetch table data
-    queryList() {
-      this.fetchList(this.params, this.page);
-    },
-    // reset to fetch table data
-    resetList() {
-      this.page.pageNum = 1;
-      this.params = initParams(this.searchColumns);
-      this.fetchList(this.params, this.page);
-    },
-    // size change to fetch table data
-    pageSizeChange(prop) {
-      this.page.pageSize = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // number change to fetch table data
-    pageNumberChange(prop) {
-      this.page.pageNum = prop;
-      this.fetchList(this.params, this.page);
-    },
-    // select row data
-    selectCurrentData(row) {
-      this.currentData = row;
-    },
-    // set row data highlight
-    setCurrentData(row) {
-      this.$refs.singleTable.setCurrentRow(row);
-    },
-    //
-    confirm() {
-      if (this.currentData) {
-        this.$emit("confirm", this.currentData);
-      }
-      this.setVisible(false);
-    },
-  },
-  created() {},
-  mounted() {},
-  destroyed() {},
-};
-</script>
-<template>
-  <el-dialog
-    :title="title"
-    :visible.sync="visible"
-    :width="width"
-    append-to-body
-    @open="beforeOpen"
-  >
-    <el-form :size="size" :inline="true" :model="params">
-      <el-form-item
-        v-for="(column, index) in searchColumns"
-        :key="index"
-        :label="column.title"
-      >
-        <el-input v-model="params[column.key]" @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-table
-      v-loading="loading"
-      :data="data"
-      :size="size"
-      ref="singleTable"
-      height="45vh"
-      highlight-current-row
-      style="width: 100%; margin-bottom: 20px"
-      @row-click="selectCurrentData"
-    >
-      <el-table-column
-        v-for="(column, index) in tableColumns"
-        :key="index"
-        :prop="column.key"
-        :label="column.title"
-        :width="column.width"
-        show-overflow-tooltip
-      >
-      </el-table-column>
-    </el-table>
-    <div
-      style="display: flex; justify-content: space-between; align-items: center"
-    >
-      <p>
-        <span style="font-size: 12px">已选择 :</span>
-        <el-tag v-if="currentData" :size="size">{{
-          currentData[showKey]
-        }}</el-tag>
-        <span v-else>无</span>
-      </p>
-      <el-pagination
-        :layout="layout"
-        :total="page.total"
-        :page-sizes="pageSizes"
-        :page-size="page.pageSize"
-        :current-page="page.pageNum"
-        :small="size === 'mini'"
-        background
-        @size-change="pageSizeChange"
-        @current-change="pageNumberChange"
-      >
-      </el-pagination>
-    </div>
-    <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">确 定</el-button>
-    </div>
-  </el-dialog>
-</template>
-<style scoped></style>

+ 0 - 3
src/views/common-dialog/utils/init-something.js

@@ -1,3 +0,0 @@
-import { arr2obj } from "@/utils/data-transform";
-
-export const initParams = (arr) => arr2obj(arr, "key", "value");

+ 2 - 1
src/views/common-dialog/api/index.js → src/views/input-dialog/api/index.js

@@ -8,10 +8,11 @@ export function list(url, params) {
   });
 }
 
-export function refer(data) {
+export function refer(data, params) {
   return request({
     url: `/refer/query`,
     method: "POST",
     data: data,
+    params: params,
   });
 }

+ 30 - 0
src/views/input-dialog/components/CURRENCY_PARAM.js

@@ -0,0 +1,30 @@
+export default [
+  {
+    key: "name",
+    title: "币种",
+    type: "Input",
+    search: true,
+  },
+  {
+    key: "code",
+    title: "币种简称",
+    type: "Input",
+    search: true,
+  },
+  {
+    key: "",
+    title: "单价精度",
+  },
+  {
+    key: "",
+    title: "单价舍入规则",
+  },
+  {
+    key: "",
+    title: "金额精度",
+  },
+  {
+    key: "",
+    title: "金额舍入规则",
+  },
+];

+ 14 - 0
src/views/input-dialog/components/DEPT_PARAM.js

@@ -0,0 +1,14 @@
+export default [
+  {
+    key: "code",
+    title: "组织编码",
+    type: "Input",
+    search: true,
+  },
+  {
+    key: "name",
+    title: "组织名称",
+    type: "Input",
+    search: true,
+  },
+];

+ 14 - 0
src/views/input-dialog/components/ORG_PARAM.js

@@ -0,0 +1,14 @@
+export default [
+    {
+      key: "code",
+      title: "组织编码",
+      type: "Input",
+      search: true,
+    },
+    {
+      key: "name",
+      title: "组织名称",
+      type: "Input",
+      search: true,
+    },
+  ]

+ 14 - 0
src/views/input-dialog/components/SUPPLIER_PARAM.js

@@ -0,0 +1,14 @@
+export default [
+  {
+    key: "code",
+    title: "供应商编码",
+    type: "Input",
+    search: true,
+  },
+  {
+    key: "name",
+    title: "供应商名称",
+    type: "Input",
+    search: true,
+  },
+];

+ 39 - 50
src/views/common-dialog/supplier.vue → src/views/input-dialog/components/index.vue

@@ -1,45 +1,35 @@
 <script>
-import { initParams } from "./utils/init-something";
-import { list } from "./api/index";
+import { refer } from "../api/index";
+import { initParams, initPage, initLayout, initPageSizes } from "@/utils/init";
+import InitColumnHooks from "./init-column";
 
 export default {
-  name: "SupplierInputDialog",
-  props: ["title", "value"],
+  name: "InputDialog",
+  props: ["title", "type"],
   components: {},
   data() {
-    const columns = [
-      {
-        key: "code",
-        title: "供应商编码",
-        type: "Input",
-        search: true,
-      },
-      {
-        key: "name",
-        title: "供应商名称",
-        type: "Input",
-        search: true,
-      },
-    ];
-    const initTableColumns = () => columns.filter((column) => column.key);
-    const initSearchColumns = () => columns.filter((column) => column.search);
+    const Page = initPage();
+    const Layout = initLayout();
+    const PageSizes = initPageSizes();
+    const { type } = this.$props;
+    const { TableColumns, SearchColumns } = InitColumnHooks(type);
+    const Params = initParams(SearchColumns);
     return {
       // global
       size: "mini",
       width: "50%",
-      page: { pageNum: 1, pageSize: 25, total: 0 },
-      pageSizes: [25, 50],
-      layout: "prev, pager, next, jumper",
-      api: "puSupplier",
       showKey: "name",
+      page: Page,
+      layout: Layout,
+      pageSizes: PageSizes,
       // dialog
       visible: false,
       loading: false,
       // search
-      searchColumns: initSearchColumns(),
-      params: initParams(initSearchColumns()),
+      searchColumns: SearchColumns,
+      params: Params,
       // table
-      tableColumns: initTableColumns(),
+      tableColumns: TableColumns,
       data: [],
       currentData: null,
     };
@@ -53,20 +43,22 @@ export default {
     },
     // do something before dialog open
     beforeOpen() {
-      const { value } = this.$props;
-      this.params[this.showKey] = value;
       this.fetchList(this.params, this.page);
     },
     // fetch table data
     async fetchList(prop, page) {
       try {
         this.loading = true;
+        const { type } = this.$props;
         const { pageNum, pageSize } = page;
-        const { code, msg, rows, total } = await list(this.api, {
-          ...prop,
-          pageNum,
-          pageSize,
-        });
+        const { code, msg, rows, total } = await refer(
+          {
+            ...prop,
+            type: type,
+            isPage: true,
+          },
+          { pageNum, pageSize }
+        );
         if (code === 200) {
           this.data = rows;
           this.page.total = total;
@@ -78,11 +70,6 @@ export default {
         this.$notify.error({ title: "error", message: err });
       } finally {
         this.loading = false;
-        this.setCurrentData(
-          this.data.find(
-            (column) => column[this.showKey] === this.currentData[this.showKey]
-          )
-        );
       }
     },
     // setting up to fetch table data
@@ -105,18 +92,18 @@ export default {
       this.page.pageNum = prop;
       this.fetchList(this.params, this.page);
     },
-    // select row data
-    selectCurrentData(row) {
+    // click select row data
+    clickSelectCurrentData(row) {
       this.currentData = row;
     },
-    // set row data highlight
-    setCurrentData(row) {
-      this.$refs.singleTable.setCurrentRow(row);
+    // double click select row data and confirm
+    dblclickSelectCurrentData(row) {
+      confirm(row);
     },
     //
-    confirm() {
-      if (this.currentData) {
-        this.$emit("confirm", this.currentData);
+    confirm(prop) {
+      if (prop) {
+        this.$emit("confirm", prop);
       }
       this.setVisible(false);
     },
@@ -150,11 +137,11 @@ export default {
       v-loading="loading"
       :data="data"
       :size="size"
-      ref="singleTable"
       height="45vh"
       highlight-current-row
       style="width: 100%; margin-bottom: 20px"
-      @row-click="selectCurrentData"
+      @row-click="clickSelectCurrentData"
+      @row-dblclick="dblclickSelectCurrentData"
     >
       <el-table-column
         v-for="(column, index) in tableColumns"
@@ -191,7 +178,9 @@ export default {
     </div>
     <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">确 定</el-button>
+      <el-button :size="size" type="primary" @click="confirm(currentData)"
+        >确 定</el-button
+      >
     </div>
   </el-dialog>
 </template>

+ 12 - 0
src/views/input-dialog/components/init-column.js

@@ -0,0 +1,12 @@
+export default function InitColumnsHooks(prop) {
+  //
+  const TableColumns = require(`./${prop}`).default.filter(
+    (element) => element.key
+  );
+  //
+  const SearchColumns = require(`./${prop}`).default.filter(
+    (element) => element.search
+  );
+  //
+  return { TableColumns, SearchColumns };
+}

+ 53 - 0
src/views/input-dialog/index.vue

@@ -0,0 +1,53 @@
+<script>
+export default {
+  name: "DrInputDialog",
+  props: ["value", "title", "type", "dataMapping", "source"],
+  components: {
+    InputDialog: () => import("./components/index.vue"),
+  },
+  data() {
+    return {};
+  },
+  computed: {},
+  watch: {},
+  methods: {
+    handleAsyncOpenDialog() {
+      this.$emit("before-open");
+      this.$nextTick(() => {
+        const { setVisible } = this.$refs.InputDialogFef;
+        setVisible(true);
+      });
+    },
+    handleUpdateSource(prop) {
+      const { source, dataMapping } = this.$props;
+      for (let key in dataMapping) {
+        source[key] = prop[dataMapping[key]];
+      }
+      this.$emit("update:source", source);
+    },
+  },
+  created() {
+    console.log("prop", this.$props);
+  },
+  mounted() {},
+  destroyed() {},
+};
+</script>
+<template>
+  <el-input
+    v-model="value"
+    style="width: 100%; cursor: pointer"
+    @click.native.stop="handleAsyncOpenDialog"
+  >
+    <template #suffix>
+      <el-icon class="el-icon-thumb"></el-icon>
+      <input-dialog
+        ref="InputDialogFef"
+        :title="title"
+        :type="type"
+        @confirm="handleUpdateSource"
+      ></input-dialog>
+    </template>
+  </el-input>
+</template>
+<style scoped></style>

+ 80 - 61
src/views/purchase/purchase-contract/add/column.js

@@ -1,11 +1,14 @@
-const columns = [
+export const Columns = [
   {
-    key: "puOrg",
+    key: "puOrgName",
     title: "采购组织",
     type: "InputDialog",
     config: {
-      componentName: "Organization",
-      dataMapping: { puOrg: "deptName" },
+      componentName: "ORG_PARAM",
+      dataMapping: {
+        puOrg: "code",
+        puOrgName: "name",
+      },
     },
     require: true,
   },
@@ -17,25 +20,30 @@ const columns = [
     require: true,
   },
   {
-    key: "buyer",
+    key: "buyerName",
     title: "采购员",
     type: "InputDialog",
     config: {
       componentName: "User",
       dataMapping: {
-        buyer: "userName",
-        puDept: "deptName",
+        buyer: "userId",
+        buyerName: "userName",
+        puDept: "deptId",
+        puDeptName: "deptName",
       },
     },
     require: true,
   },
   {
-    key: "supplier",
+    key: "supplierName",
     title: "供应商",
     type: "InputDialog",
     config: {
-      componentName: "Supplier",
-      dataMapping: { supplier: "name" },
+      componentName: "SUPPLIER_PARAM",
+      dataMapping: {
+        supplier: "code",
+        supplierName: "name",
+      },
     },
     require: true,
   },
@@ -51,14 +59,20 @@ const columns = [
   {
     key: "puMoneyYear",
     title: "本年度采购额",
-    type: "Input",
+    type: "InputNumber",
     require: true,
   },
   {
-    key: "puDept",
+    key: "puDeptName",
     title: "采购部门",
     type: "InputDialog",
-    config: { componentName: "Department" },
+    config: {
+      componentName: "DEPT_PARAM",
+      dataMapping: {
+        puDept: "code",
+        puDeptName: "name",
+      },
+    },
     require: true,
   },
   {
@@ -100,7 +114,6 @@ const columns = [
     title: "合同生效日期",
     type: "DatePicker",
     require: true,
-    config: { type: "date" },
   },
   {
     key: "brandGrossRate",
@@ -125,7 +138,6 @@ const columns = [
     title: "合同终止日期",
     type: "DatePicker",
     require: true,
-    config: { type: "date" },
   },
   {
     key: "invoiceTax",
@@ -154,7 +166,6 @@ const columns = [
     title: "合同签订日期",
     type: "DatePicker",
     require: true,
-    config: { type: "date" },
   },
   {
     key: "deliveryType",
@@ -172,13 +183,14 @@ const columns = [
     disabled: true,
   },
   {
-    key: "contractPartyc",
+    key: "contractPartycName",
     title: "合同丙方",
     type: "InputDialog",
     config: {
-      componentName: "Supplier",
+      componentName: "SUPPLIER_PARAM",
       dataMapping: {
-        contractPartyc: "name",
+        contractPartyc: "code",
+        contractPartycName: "name",
       },
     },
   },
@@ -201,7 +213,6 @@ const columns = [
     title: "合同创建时间",
     type: "DatePicker",
     disabled: true,
-    config: { type: "date" },
   },
   {
     key: "isTarget",
@@ -288,16 +299,16 @@ const columns = [
     key: "taxPrice",
     title: "价税合计",
     type: "InputNumber",
-    config: { controlsPosition: "right" },
   },
   {
-    key: "currency",
+    key: "currencyName",
     title: "币种",
     type: "InputDialog",
     config: {
-      componentName: "Currency",
+      componentName: "CURRENCY_PARAM",
       dataMapping: {
-        currency: "name",
+        currency: "code",
+        currencyName: "name",
       },
     },
     require: true,
@@ -319,15 +330,13 @@ const columns = [
   // { key: "delFlag", title: "删除标记" },
 ];
 
-export const initColumns = () => columns;
-
-const tabColumns = [
+export const TabColumns = [
   {
     show: {
       contractType: [1, 2],
     },
     title: "物料基本信息",
-    key: "PuContractItem",
+    key: "contractItemList",
     tableColumns: [
       { title: "序号", key: "index" },
       { title: "物料编码", key: "material", width: 200 },
@@ -357,14 +366,14 @@ const tabColumns = [
         title: "采购数量",
         key: "qty",
         type: "InputNumber",
-        config: { controlsPosition: "right" },
+
         width: 200,
       },
       {
         title: "含税单价",
         key: "taxPrice",
         type: "InputNumber",
-        config: { controlsPosition: "right" },
+
         width: 200,
       },
       { title: "含税金额合计", key: "taxMoney", width: 200 },
@@ -382,57 +391,67 @@ const tabColumns = [
         type: "InputDialog",
         width: 200,
       },
-      // { title: "备注", key: "remark", type: "Input", width: 200 },
+      { title: "备注", key: "remark", type: "Input", width: 200 },
     ],
   },
   {
     title: "合同条款",
-    key: "PuContractClause",
+    key: "contractClauseList",
     tableColumns: [
-      { title: "序号", key: "" },
-      { title: "条款编码", key: "" },
-      { title: "条款名称", key: "" },
-      { title: "条款内容", key: "" },
-      { title: "变量序号", key: "" },
-      { title: "变量内容", key: "" },
-      // { title: "备注", key: "" },
+      { title: "序号", key: "index" },
+      { title: "条款编码", key: "code", type: "Input" },
+      { title: "条款名称", key: "name", type: "Input" },
+      { title: "条款内容", key: "content", type: "Input" },
+      { title: "变量序号", key: "variableRowno" },
+      { title: "变量内容", key: "variableContent", type: "Input" },
+      { title: "备注", key: "remark", type: "Input" },
     ],
   },
   {
     title: "合同费用",
-    key: "PuContractExpense",
+    key: "contractExpenseList",
     tableColumns: [
-      { title: "序号", key: "" },
-      { title: "费用编码", key: "" },
-      { title: "费用名称", key: "" },
-      { title: "费用金额", key: "" },
-      { title: "备注", key: "" },
+      { title: "序号", key: "index" },
+      { title: "费用编码", key: "code", type: "Input" },
+      { title: "费用名称", key: "name", type: "Input" },
+      {
+        title: "费用金额",
+        key: "money",
+        type: "InputNumber",
+        width: 200,
+      },
+      { title: "备注", key: "remark", type: "Input" },
     ],
   },
   {
     title: "付款协议信息",
-    key: "PuContractAgreement",
+    key: "contractAgreementList",
     tableColumns: [
-      { title: "序号", key: "" },
-      { title: "付款阶段", key: "" },
-      { title: "是否预付款", key: "" },
-      { title: "是否质保金", key: "" },
-      { title: "结算方式", key: "" },
-      { title: "付款起点", key: "" },
-      { title: "付款金额", key: "" },
-      { title: "付款比例%", key: "" },
-      { title: "账期天数", key: "" },
-      { title: "备注", key: "" },
+      { title: "序号", key: "index" },
+      {
+        title: "付款阶段",
+        key: "satge",
+        type: "InputNumber",
+        width: 200,
+      },
+      { title: "付款起点", key: "origin", type: "InputDialog", width: 200 },
+      { title: "账期天数", key: "paymetDays", type: "Input", width: 200 },
+      { title: "付款比例%", key: "ratio", type: "Input", width: 200 },
+      { title: "付款金额", key: "money", type: "Input", width: 200 },
+      { title: "是否预付款", key: "isAdvance" },
+      { title: "是否质保金", key: "isQuality" },
+      { title: "结算方式", key: "paymentMeans", type: "Input", width: 200 },
+      { title: "备注", key: "remark", type: "Input", width: 200 },
+      { title: "需进度确认", key: "schedule", type: "Select", width: 200 },
     ],
   },
   {
     title: "合同执行组织范围",
-    key: "PuContractApplyOrg",
+    key: "contractApplyOrgList",
     tableColumns: [
-      { title: "序号", key: "" },
-      { title: "组织名称", key: "" },
-      { title: "组织编码", key: "" },
+      { title: "序号", key: "index" },
+      { title: "组织名称", key: "orgName", type: "Input" },
+      { title: "组织编码", key: "org", type: "Input" },
     ],
   },
 ];
-export const initTabColumns = () => tabColumns;

+ 120 - 127
src/views/purchase/purchase-contract/add/index.vue

@@ -1,117 +1,101 @@
 <script>
+import { initColumns, initDicts, initRules, initParams } from "@/utils/init";
+import { Columns, TabColumns } from "./column";
 import { add } from "@/api/business/purchase/purchase-contract";
-import { arr2obj } from "@/utils/data-transform";
-import {
-  initDicts,
-  initRules,
-  initParams,
-  initComponents,
-} from "@/utils/init-something";
-import { initColumns, initTabColumns } from "./column";
+
+const NewColumns = initColumns(Columns);
+const NewTabColumns = TabColumns.map((element) => ({
+  ...element,
+  tableColumns: initColumns(element.tableColumns),
+}));
 
 export default {
-  name: "AddPurchaseContractDrawer",
-  components: initComponents(initColumns()),
-  dicts: initDicts(initColumns()),
+  name: "AddDrawer",
+  dicts: initDicts(NewColumns),
+  components: {
+    DrInputDialog: () => import("@/views/input-dialog/index.vue"),
+  },
   data() {
     return {
-      visible: true,
-      columns: initColumns(),
-      rules: initRules(initColumns()),
-      params: initParams(initColumns()),
-      tabColumns: initTabColumns(),
-      tabName: "PuContractItem",
-      tabTableParams: {
-        PuContractItem: [],
-        PuContractClause: [],
-        PuContractExpense: [],
-        PuContractAgreement: [],
-        PuContractApplyOrg: [],
+      visible: false,
+      columns: NewColumns,
+      rules: initRules(NewColumns),
+      params: {
+        ...initParams(NewColumns),
+        contractItemList: [],
+        contractClauseList: [],
+        contractExpenseList: [],
+        contractAgreementList: [],
+        contractApplyOrgList: [],
       },
-      currentComponent: { name: "", title: "", value: "", row: {}, source: {} },
+
+      tabColumns: NewTabColumns,
+      tabName: "contractItemList",
     };
   },
   computed: {},
   watch: {},
   methods: {
     beforeOpen() {
-      const { deptName, nickName, orgName } = this.$store.state.user;
-      this.params.puOrg = orgName;
-      this.params.buyer = nickName;
-      this.params.puDept = deptName;
+      const { deptName, deptId, name, id, orgName, orgId } =
+        this.$store.state.user;
+      this.params.puOrg = orgId;
+      this.params.puOrgName = orgName;
+      this.params.buyer = id;
+      this.params.buyerName = name;
+      this.params.puDept = deptId;
+      this.params.puDeptName = deptName;
     },
     setVisible(prop) {
       this.visible = prop;
     },
     addTableRow(prop) {
-      this.$notify.info({ message: prop });
-      this.tabTableParams[prop].push(
-        arr2obj(
-          initTabColumns().find((element) => element.key === prop).tableColumns,
-          "key",
-          ""
-        )
-      );
-      console.log(this.tabTableParams);
+      const arr = this.tabColumns.find(
+        (element) => element.key === this.tabName
+      ).tableColumns;
+      prop.push(initParams(arr, "key", "value"));
     },
-    cancel() {
-      this.setVisible(false);
-      this.params = arr2obj(this.columns, "key", "value");
+    delTableRow(prop, index) {
+      prop.splice(index, 1);
     },
-    sava() {
+    // 取消
+    handleCancel() {
       this.setVisible(false);
+      this.params = initParams(this.columns, "key", "value");
     },
-    async submitSava() {
-      console.log(this.params);
-      return;
-      try {
-        const res = await add(this.params);
-        console.log("res", res);
-      } catch (err) {
-        this.$notify.error({ title: "error", message: err });
-      } finally {
-        this.setVisible(false);
-      }
+    // 保存
+    handleSava() {
+      this.setVisible(false);
     },
-    //
-    openAsyncInputDialog(prop, source, type) {
+    // 保存并新增
+    async handleSubmit() {
       try {
-        const {
-          key,
-          title,
-          config: { componentName },
-        } = prop;
-        this.currentComponent.row = prop;
-        this.currentComponent.title = title;
-        this.currentComponent.name = componentName;
-        this.currentComponent.source = source;
-        if (type === "change") {
-          this.currentComponent.value = this.params[key];
-        }
-        if (type === "click") {
-          this.currentComponent.value = "";
-        }
-        this.$nextTick(() => {
-          const { setVisible } = this.$refs[componentName];
-          setVisible(true);
+        const createById = this.params.buyer;
+        const createByName = this.params.buyerName;
+        const updateById = this.$store.state.user.id;
+        const updateByName = this.$store.state.user.name;
+        const { code, msg } = await add({
+          createById,
+          createByName,
+          updateById,
+          updateByName,
+          ...this.params,
         });
+        if (code === 200) {
+          this.$notify.success({ title: msg });
+          this.setVisible(false);
+        } else {
+          this.$notify.warning({ title: msg });
+        }
       } catch (err) {
         this.$notify.error({ title: "error", message: err });
       } finally {
-        console.log(this.currentComponent, source, this.tabTableParams);
-      }
-    },
-    updateParams(prop) {
-      const {
-        config: { dataMapping },
-      } = this.currentComponent.row;
-      for (let key in dataMapping) {
-        this.currentComponent.source[key] = prop[dataMapping[key]];
+        // this.setVisible(false);
       }
     },
   },
   created() {
-    // console.log("this,", initComponents(initColumns()));
+    console.log("ADD CREATED");
   },
   mounted() {},
   destroyed() {},
@@ -124,6 +108,7 @@ export default {
     :with-header="false"
     :visible.sync="visible"
     @open="beforeOpen"
+    @close="$emit('close')"
   >
     <el-form
       size="mini"
@@ -150,21 +135,15 @@ export default {
         >
           <h3>新增</h3>
           <div style="text-align: right">
-            <el-button size="mini" @click="cancel">取消</el-button>
-            <el-button size="mini" type="danger" @click="sava">保存</el-button>
-            <el-button size="mini" type="info" @click="submitSava">
+            <el-button size="mini" @click="handleCancel">取消</el-button>
+            <el-button size="mini" type="danger" @click="handleSava"
+              >保存</el-button
+            >
+            <el-button size="mini" type="info" @click="handleSubmit">
               保存并新增
             </el-button>
           </div>
         </div>
-        <component
-          v-if="currentComponent.name"
-          :is="currentComponent.name"
-          :ref="currentComponent.name"
-          :title="currentComponent.title"
-          :value="currentComponent.value"
-          @confirm="updateParams"
-        ></component>
         <el-row>
           <el-col
             v-for="(column, index) in columns"
@@ -180,26 +159,19 @@ export default {
                 :disabled="column.disabled"
                 style="width: 100%"
               ></el-input>
-              <el-input
+              <dr-input-dialog
                 v-if="column.type === 'InputDialog'"
                 v-model="params[column.key]"
                 :placeholder="column.placeholder"
                 :clearable="column.clearable"
                 :disabled="column.disabled"
-                style="width: 100%"
-                @blur="openAsyncInputDialog(column, params, 'change')"
-                @change="openAsyncInputDialog(column, params, 'change')"
+                :readonly="column.readonly"
+                :title="column.title"
+                :type="column.config.componentName"
+                :data-mapping="column.config.dataMapping"
+                :source.sync="params"
               >
-                <template #suffix>
-                  <el-icon
-                    class="el-icon-s-operation"
-                    style="cursor: pointer"
-                    @click.native.stop="
-                      openAsyncInputDialog(column, params, 'change')
-                    "
-                  ></el-icon>
-                </template>
-              </el-input>
+              </dr-input-dialog>
               <el-input
                 v-if="column.type === 'Textarea'"
                 v-model="params[column.key]"
@@ -247,7 +219,7 @@ export default {
               >
                 <template #prefix>
                   <el-icon
-                    class="el-icon-s-operation"
+                    class="el-icon-view"
                     style="cursor: pointer"
                     @click.stop="$message.info(234)"
                   ></el-icon>
@@ -300,14 +272,14 @@ export default {
         }"
         style="margin: 10px"
       >
-        <el-tabs v-model="tabName" @tab-click="handleClick" style="width: 100%">
+        <el-tabs v-model="tabName" style="width: 100%">
           <el-tab-pane
             v-for="(column, index) in tabColumns"
             :key="index"
             :label="column.title"
             :name="column.key"
           >
-            <el-table :data="tabTableParams[column.key]" style="width: 100%">
+            <el-table :data="params[column.key]" style="width: 100%">
               <el-table-column
                 v-for="(cColumn, cIndex) in column.tableColumns"
                 :key="cIndex"
@@ -328,44 +300,65 @@ export default {
                     size="mini"
                     style="width: 100%"
                   ></el-input>
-                  <el-input-number
-                    v-if="cColumn.type === 'InputNumber'"
+                  <dr-input-dialog
+                    v-if="cColumn.type === 'InputDialog'"
                     v-model="scope.row[cColumn.key]"
-                    :controls-position="cColumn.config.controlsPosition"
                     :placeholder="cColumn.placeholder"
                     :clearable="cColumn.clearable"
                     :disabled="cColumn.disabled"
+                    :readonly="cColumn.readonly"
+                    :title="cColumn.title"
+                    :type="cColumn.config.componentName"
+                    :data-mapping="cColumn.config.dataMapping"
+                    :source.sync="scope.row"
                     size="mini"
-                    style="width: 100%"
-                  ></el-input-number>
-                  <el-input
-                    v-if="cColumn.type === 'InputDialog'"
+                  >
+                  </dr-input-dialog>
+                  <el-input-number
+                    v-if="cColumn.type === 'InputNumber'"
                     v-model="scope.row[cColumn.key]"
+                    :controls-position="cColumn.config.controlsPosition"
                     :placeholder="cColumn.placeholder"
                     :clearable="cColumn.clearable"
                     :disabled="cColumn.disabled"
                     size="mini"
                     style="width: 100%"
-                    @blur="openAsyncInputDialog(cColumn, scope.row, 'change')"
-                    @change="openAsyncInputDialog(cColumn, scope.row, 'change')"
+                  ></el-input-number>
+                  <el-input
+                    v-if="column.type === 'InputDialog'"
+                    v-model="params[column.key]"
+                    :placeholder="column.placeholder"
+                    :clearable="column.clearable"
+                    :disabled="column.disabled"
+                    :readonly="column.readonly"
+                    style="width: 100%; cursor: pointer"
                   >
                     <template #suffix>
-                      <el-icon
-                        class="el-icon-s-operation"
-                        style="cursor: pointer"
-                        @click.native.stop="
-                          openAsyncInputDialog(cColumn, scope.row, 'click')
-                        "
-                      ></el-icon>
+                      <el-icon class="el-icon-thumb"></el-icon>
                     </template>
                   </el-input>
                 </template>
               </el-table-column>
+              <el-table-column fixed="right" label="操作" width="120">
+                <template slot-scope="scope">
+                  <el-button
+                    @click.native.prevent="
+                      delTableRow(params[tabName], scope.$index)
+                    "
+                    type="text"
+                    size="small"
+                  >
+                    删行
+                  </el-button>
+                </template>
+              </el-table-column>
             </el-table>
           </el-tab-pane>
         </el-tabs>
         <el-row style="position: absolute; top: 20px; right: 20px">
-          <el-button size="mini" @click="addTableRow(tabName)">增行</el-button>
+          <el-button size="mini" @click="addTableRow(params[tabName])"
+            >增行</el-button
+          >
         </el-row>
       </el-card>
     </el-form>

+ 64 - 0
src/views/purchase/purchase-contract/column.js

@@ -0,0 +1,64 @@
+export const TableColumns = [
+  { key: "id", title: "id" },
+  { key: "puOrg", title: "采购组织" },
+  { key: "puOrgName", title: "采购组织名称" },
+  { key: "code", title: "合同编码" },
+  { key: "lastPuMoney", title: "上年度采购额" },
+  { key: "buyer", title: "采购员" },
+  { key: "buyerName", title: "采购员名称" },
+  { key: "supplier", title: "供应商" },
+  { key: "supplierName", title: "供应商名称" },
+  { key: "contractType", title: "合同类型" },
+  { key: "puMoneyYear", title: "本年度采购额" },
+  { key: "puDept", title: "采购部门" },
+  { key: "puDeptName", title: "采购部门名称" },
+  { key: "supplierTier", title: "供应商层级" },
+  { key: "contractName", title: "合同名称", search: true, type: "Input" },
+  { key: "grossRateAverage", title: "平均毛利率" },
+  { key: "approveFlow", title: "审批流程" },
+  { key: "consumableClass", title: "耗材类别" },
+  { key: "effectiveDate", title: "合同生效日期" },
+  { key: "brandGrossRate", title: "同类品牌及毛利率" },
+  { key: "contractFormat", title: "合同格式" },
+  { key: "productName", title: "产品类别&名称" },
+  { key: "endDate", title: "合同终止日期" },
+  { key: "invoiceTax", title: "发票税率" },
+  { key: "emergencyDegree", title: "紧急程度" },
+  { key: "project", title: "项目医院" },
+  { key: "signDate", title: "合同签订日期" },
+  { key: "deliveryType", title: "交货方式" },
+  { key: "source", title: "合同来源" },
+  { key: "contractPartyc", title: "合同丙方" },
+  { key: "contractPartycName", title: "合同丙方名称" },
+  { key: "guaranteePeriodEnd", title: "质保期限" },
+  { key: "freightMethods", title: "运费承担方式" },
+  { key: "isTarget", title: "是否有指标" },
+  { key: "contractTarget", title: "合同指标" },
+  { key: "exemptionPostageCondtion", title: "包邮条件" },
+  { key: "isRebate", title: "是否有返利" },
+  { key: "rebatePolicy", title: "返利政策" },
+  { key: "externalContract", title: "外部合同号" },
+  { key: "rollbackPolicy", title: "退换货政策" },
+  { key: "contractContent", title: "合同主要内容" },
+  { key: "refusalReasons", title: "拒绝理由" },
+  { key: "enquiryCode", title: "询价单号" },
+  { key: "externalFile", title: "对外附件" },
+  { key: "supplierFile", title: "供应商盖章合同附件" },
+  { key: "puFile", title: "采购商盖章合同附件" },
+  { key: "projectCode", title: "项目编号" },
+  { key: "projectName", title: "项目名称" },
+  { key: "area", title: "区域区域" },
+  { key: "consigneePhone", title: "收货人联系方式" },
+  { key: "paymentAgreement", title: "付款协议" },
+  { key: "taxPrice", title: "价税合计" },
+  { key: "currency", title: "币种" },
+  { key: "currencyName", title: "币种名称" },
+  { key: "guaranteePeriod", title: "质保期" },
+  { key: "tenantId", title: "租户号" },
+  { key: "revision", title: "乐观锁" },
+  { key: "createByName", title: "创建人" },
+  { key: "updateByName", title: "创建人名称" },
+  { key: "delFlag", title: "删除标记" },
+];
+
+export const SearchColumns = TableColumns.filter((element) => element.search);

+ 116 - 180
src/views/purchase/purchase-contract/index.vue

@@ -1,136 +1,46 @@
 <script>
-import { list } from "@/api/business/purchase/purchase-contract";
-import AddPurchaseContractDrawer from "./add/index.vue";
-import SeePurchaseContractDrawer from "./see-purchase-contract.vue";
-// import DirectSourcingTable from "./direct-sourcing.vue";
+import { TableColumns, SearchColumns } from "./column";
+import { list, remove } from "@/api/business/purchase/purchase-contract";
+import { initPage, initLayout, initPageSizes, initParams } from "@/utils/init";
 export default {
-  name: "PuchaseTask",
+  name: "PuchaseContract",
   components: {
-    AddPurchaseContractDrawer,
-    SeePurchaseContractDrawer,
-    // DirectSourcingTable,
+    AddDrawer: () => import("./add/index.vue"),
+    SeeDrawer: () => import("./see/index.vue"),
   },
   data() {
-    const arr2Obj = function (data, keyName, valueName) {
-      return Object.fromEntries(
-        data.map((item) => [item[keyName], item[valueName]])
-      );
-    };
-    const searchColumns = [
-      { title: "合同名称", key: "contractName", type: "Input" },
-    ];
-    const initSearchColumns = () => searchColumns;
-    const initSearchParams = () => arr2Obj(initSearchColumns(), "key", "value");
-    const tableColumns = [
-      { key: "id", title: "id" },
-      { key: "puOrg", title: "采购组织" },
-      { key: "puOrgName", title: "采购组织名称" },
-      { key: "code", title: "合同编码" },
-      { key: "lastPuMoney", title: "上年度采购额" },
-      { key: "buyer", title: "采购员" },
-      { key: "buyerName", title: "采购员名称" },
-      { key: "supplier", title: "供应商" },
-      { key: "supplierName", title: "供应商名称" },
-      { key: "contractType", title: "合同类型" },
-      { key: "puMoneyYear", title: "本年度采购额" },
-      { key: "puDept", title: "采购部门" },
-      { key: "puDeptName", title: "采购部门名称" },
-      { key: "supplierTier", title: "供应商层级" },
-      { key: "contractName", title: "合同名称" },
-      { key: "grossRateAverage", title: "平均毛利率" },
-      { key: "approveFlow", title: "审批流程" },
-      { key: "consumableClass", title: "耗材类别" },
-      { key: "effectiveDate", title: "合同生效日期" },
-      { key: "brandGrossRate", title: "同类品牌及毛利率" },
-      { key: "contractFormat", title: "合同格式" },
-      { key: "productName", title: "产品类别&名称" },
-      { key: "endDate", title: "合同终止日期" },
-      { key: "invoiceTax", title: "发票税率" },
-      { key: "emergencyDegree", title: "紧急程度" },
-      { key: "project", title: "项目医院" },
-      { key: "signDate", title: "合同签订日期" },
-      { key: "deliveryType", title: "交货方式" },
-      { key: "source", title: "合同来源" },
-      { key: "contractPartyc", title: "合同丙方" },
-      { key: "contractPartycName", title: "合同丙方名称" },
-      { key: "guaranteePeriodEnd", title: "质保期限" },
-      { key: "freightMethods", title: "运费承担方式" },
-      { key: "isTarget", title: "是否有指标" },
-      { key: "contractTarget", title: "合同指标" },
-      { key: "exemptionPostageCondtion", title: "包邮条件" },
-      { key: "isRebate", title: "是否有返利" },
-      { key: "rebatePolicy", title: "返利政策" },
-      { key: "externalContract", title: "外部合同号" },
-      { key: "rollbackPolicy", title: "退换货政策" },
-      { key: "contractContent", title: "合同主要内容" },
-      { key: "refusalReasons", title: "拒绝理由" },
-      { key: "enquiryCode", title: "询价单号" },
-      { key: "externalFile", title: "对外附件" },
-      { key: "supplierFile", title: "供应商盖章合同附件" },
-      { key: "puFile", title: "采购商盖章合同附件" },
-      { key: "projectCode", title: "项目编号" },
-      { key: "projectName", title: "项目名称" },
-      { key: "area", title: "区域区域" },
-      { key: "consigneePhone", title: "收货人联系方式" },
-      { key: "paymentAgreement", title: "付款协议" },
-      { key: "taxPrice", title: "价税合计" },
-      { key: "currency", title: "币种" },
-      { key: "currencyName", title: "币种名称" },
-      { key: "guaranteePeriod", title: "质保期" },
-      { key: "tenantId", title: "租户号" },
-      { key: "revision", title: "乐观锁" },
-      { key: "createByName", title: "创建人" },
-      { key: "updateByName", title: "创建人名称" },
-      { key: "delFlag", title: "删除标记" },
-    ];
-    const initTableColumns = () => tableColumns;
     return {
       loading: false,
-      isSimpleSearch: true,
-      searchColumns: initSearchColumns(),
-      searchParams: {
-        isAsc: "desc",
-        reasonable: "",
-        orderByColumn: "",
-        ...initSearchParams(),
-      },
-      tableColumns: initTableColumns(),
-      tableData: [{ materialName: 1 }],
-      page: { pageNum: 1, pageSize: 25 },
-      total: 0,
-      pageSizes: [25, 50, 100],
+
+      pageSizes: initPageSizes(),
+      layout: initLayout(),
+      page: initPage(),
+
+      searchColumns: SearchColumns,
+      params: initParams(SearchColumns),
+
+      tableColumns: TableColumns,
+      tableData: [],
     };
   },
-  computed: {
-    showSearchColumns() {
-      return this.isSimpleSearch
-        ? this.searchColumns.slice(0, 4)
-        : this.searchColumns;
-    },
-  },
-  //   watch: {
-  //     $route: {
-  //       handler: function (route) {
-  //         this.redirect = route.query && route.query.redirect;
-  //       },
-  //       immediate: true,
-  //     },
-  //   },
+  computed: {},
   created() {
-    this.fetchTaskList();
-    console.log("Vue", this);
+    this.handleQueryList();
   },
   methods: {
-    async fetchTaskList() {
-      this.loading = true;
+    //
+    async fetchList(params, page) {
       try {
+        this.loading = true;
+        const { pageNum, pageSize } = page;
         const { code, msg, rows, total } = await list({
-          ...this.page,
-          ...this.searchParams,
+          pageNum,
+          pageSize,
+          ...params,
         });
         if (code === 200) {
-          this.total = total;
           this.tableData = rows;
+          this.page.total = total;
           this.$notify.success({ title: msg });
         } else {
           this.$notify.warning({ title: msg });
@@ -141,27 +51,60 @@ export default {
         this.loading = false;
       }
     },
-    handleSearchChange() {
-      this.isSimpleSearch = !this.isSimpleSearch;
-      this.$notify.info({
-        title: this.isSimpleSearch ? "Simple Search" : "All Search",
-      });
+    // 查询操作
+    handleQueryList() {
+      this.fetchList(this.params, this.page);
+    },
+    // 重置操作
+    handleResetList() {
+      this.page = initPage();
+      this.params = initParams();
+      this.fetchList(this.params, this.page);
     },
-    handleSizeChange() {},
-    handleCurrentChange() {},
+    // 刷新操作
+    handleRefreshList() {
+      this.fetchList(this.params, this.page);
+    },
+    // 删除操作
+    async handleDeleteList(prop) {
+      try {
+        this.loading = true;
+        const { id } = prop;
+        const { code, msg } = await remove(id);
+        if (code === 200) {
+          this.$notify.success({ title: msg });
+          this.fetchList(this.params, this.page);
+        } else {
+          this.$notify.warning({ title: msg });
+        }
+      } catch (err) {
+        this.$notify.error({ title: "error", message: err });
+      } finally {
+        this.loading = false;
+      }
+    },
+    // 页大小变
+    handleSizeChange(prop) {
+      this.page.pageSize = prop;
+      this.fetchList(this.params, this.page);
+    },
+    // 当前页变
+    handleCurrentChange(prop) {
+      this.page.pageNum = prop;
+      this.fetchList(this.params, this.page);
+    },
+    // 打开新增drawer
     handleOpenAddDrawer() {
-      const { setVisible } = this.$refs.addDrawerFef;
+      console.log(this.$refs.AddDrawerFef);
+      const { setVisible } = this.$refs.AddDrawerFef;
       setVisible(true);
-      setTimeout(() => {
-        this.$notify.info("Open Add Drawer");
-      }, 250);
     },
-    handleOpenSeeDrawer() {
-      const { setVisible } = this.$refs.seeDrawerFef;
-      setVisible(true);
-      setTimeout(() => {
-        this.$notify.info("Open See Drawer");
-      }, 250);
+    // 打开查看drawer
+    async handleOpenSeeDrawer(prop) {
+      const { id } = prop;
+      const { setVisible, fetchItem } = this.$refs.SeeDrawerFef;
+      await setVisible(true);
+      await fetchItem(id);
     },
   },
 };
@@ -173,64 +116,46 @@ export default {
     style="width: calc(100% - 24px); height: 100%; margin: 10px"
     :body-style="{ padding: 0 }"
   >
-    <AddPurchaseContractDrawer ref="addDrawerFef"></AddPurchaseContractDrawer>
-    <SeePurchaseContractDrawer ref="seeDrawerFef"></SeePurchaseContractDrawer>
+    <add-drawer ref="AddDrawerFef" @close="handleResetList"></add-drawer>
+    <see-drawer ref="SeeDrawerFef"></see-drawer>
     <el-form
       size="mini"
       label-position="right"
       label-width="85px"
-      :model="searchParams"
+      :model="params"
       style="padding: 20px 0 0 0"
     >
       <el-row :gutter="24">
-        <el-col :span="20">
-          <el-row :gutter="20">
-            <el-col
-              v-for="column in showSearchColumns"
-              :key="column.title"
-              :xl="6"
-              :lg="6"
-              :md="8"
-              :sm="12"
-              :xs="24"
-            >
-              <el-form-item :prop="column.key" :label="column.title">
-                <el-input
-                  v-model="searchParams[column.key]"
-                  :placeholder="column.placeholder"
-                ></el-input>
-              </el-form-item>
-            </el-col>
-          </el-row>
-        </el-col>
         <el-col
-          :span="3"
-          :offset="1"
-          style="text-align: right; padding-right: 40px"
+          v-for="column in searchColumns"
+          :key="column.title"
+          :xl="6"
+          :lg="6"
+          :md="8"
+          :sm="12"
+          :xs="24"
         >
-          <el-button type="primary" size="mini">搜索</el-button>
-          <el-button size="mini">重置</el-button>
+          <el-form-item :prop="column.key" :label="column.title">
+            <el-input
+              v-model="params[column.key]"
+              :placeholder="column.placeholder"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xl="6" :lg="6" :md="8" :sm="12" :xs="24">
+          <el-button type="primary" size="mini" @click="handleQueryList"
+            >搜 索</el-button
+          >
+          <el-button size="mini" @click="handleResetList">重 置</el-button>
         </el-col>
       </el-row>
     </el-form>
-    <el-divider>
-      <i
-        :class="isSimpleSearch ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
-        style="cursor: pointer"
-        @click="handleSearchChange"
-      ></i>
-    </el-divider>
     <el-row :gutter="24" style="padding: 0 20px">
-      <el-col :span="6">123</el-col>
-      <el-col :span="18" style="text-align: right">
-        <el-button
-          size="mini"
-          type="danger"
-          style="margin: 0 10px 0 0"
-          @click="handleOpenAddDrawer"
-        >
-          新增
+      <el-col :span="6">
+        <el-button size="mini" type="danger" @click="handleOpenAddDrawer">
+          新 增
         </el-button>
+        <el-button size="mini" @click="handleRefreshList"> 刷 新 </el-button>
       </el-col>
     </el-row>
     <el-table
@@ -248,16 +173,27 @@ export default {
         :show-overflow-tooltip="column.showOverflowTooltip || true"
       >
       </el-table-column>
+      <el-table-column fixed="right" label="操作" width="120">
+        <template slot-scope="scope">
+          <el-button
+            @click.native.prevent="handleDeleteList(scope.row)"
+            type="text"
+            size="small"
+          >
+            删 除
+          </el-button>
+        </template>
+      </el-table-column>
     </el-table>
     <el-pagination
       @size-change="handleSizeChange"
       @current-change="handleCurrentChange"
-      :total="total"
+      :total="page.total"
       :page-sizes="pageSizes"
       :page-size="page.pageSize"
       :current-page="page.pageNum"
-      hide-on-single-page
-      layout="total, prev, pager, next, sizes, jumper"
+      :layout="layout"
+      style="margin: 16px 0"
     >
     </el-pagination>
   </el-card>

+ 284 - 0
src/views/purchase/purchase-contract/see/index.vue

@@ -0,0 +1,284 @@
+<script>
+import {
+  initColumns,
+  initDicts,
+  initRules,
+  initParams,
+  initComponents,
+} from "@/utils/init";
+import { Columns, TabColumns } from "../add/column";
+import { item } from "@/api/business/purchase/purchase-contract";
+
+const NewColumns = initColumns(Columns, { disabled: true, readonly: true });
+const NewTabColumns = TabColumns.map((element) => ({
+  ...element,
+  tableColumns: initColumns(element.tableColumns),
+}));
+
+export default {
+  name: "SeeDrawer",
+  dicts: initDicts(NewColumns),
+  components: initComponents(NewColumns),
+  data() {
+    return {
+      visible: false,
+      columns: NewColumns,
+      rules: initRules(NewColumns),
+      params: {
+        ...initParams(NewColumns),
+        contractItemList: [],
+        contractClauseList: [],
+        contractExpenseList: [],
+        contractAgreementList: [],
+        contractApplyOrgList: [],
+      },
+
+      tabColumns: NewTabColumns,
+      tabName: "contractItemList",
+    };
+  },
+  computed: {},
+  watch: {},
+  methods: {
+    setVisible(prop) {
+      this.visible = prop;
+    },
+    //
+    async fetchItem(prop) {
+      try {
+        this.loading = true;
+        const { code, msg, data } = await item(prop);
+        if (code === 200) {
+          this.params = data;
+          this.$notify.success({ title: msg });
+        } else {
+          this.$notify.warning({ title: msg });
+        }
+      } catch (err) {
+        this.$notify.error({ title: "error", message: err });
+      } finally {
+        this.loading = false;
+      }
+    },
+    // 取 消
+    handleCancel() {
+      this.setVisible(false);
+      this.params = initParams(Columns);
+    },
+  },
+  created() {},
+  mounted() {},
+  destroyed() {},
+};
+</script>
+<template>
+  <el-drawer
+    direction="btt"
+    size="100%"
+    :with-header="false"
+    :visible.sync="visible"
+    @open="beforeOpen"
+    @close="$emit('close')"
+  >
+    <el-form
+      size="mini"
+      label-position="right"
+      label-width="135px"
+      :model="params"
+      :rules="rules"
+    >
+      <el-card
+        :body-style="{
+          padding: '20px',
+          display: 'flex',
+          'flex-wrap': 'wrap',
+        }"
+        style="margin: 10px"
+      >
+        <div
+          slot="header"
+          style="
+            display: flex;
+            justify-content: space-between;
+            align-items: center;
+          "
+        >
+          <h3>查看</h3>
+          <div style="text-align: right">
+            <el-button size="mini" @click="handleCancel">取 消</el-button>
+          </div>
+        </div>
+        <el-row>
+          <el-col
+            v-for="(column, index) in columns"
+            :key="index"
+            :span="column.span || 6"
+          >
+            <el-form-item :prop="column.key" :label="column.title">
+              <el-input
+                v-if="column.type === 'Textarea'"
+                v-model="params[column.key]"
+                type="textarea"
+                :placeholder="column.placeholder"
+                :clearable="column.clearable"
+                :disabled="column.disabled"
+                :readonly="column.readonly"
+                style="width: 100%"
+              ></el-input>
+              <el-input-number
+                v-else-if="column.type === 'InputNumber'"
+                v-model="params[column.key]"
+                :controls-position="column.config.controlsPosition"
+                :placeholder="column.placeholder"
+                :clearable="column.clearable"
+                :disabled="column.disabled"
+                :readonly="column.readonly"
+                style="width: 100%"
+              ></el-input-number>
+              <el-select
+                v-else-if="column.type === 'Select'"
+                v-model="params[column.key]"
+                :placeholder="column.placeholder"
+                :clearable="column.clearable"
+                :disabled="column.disabled"
+                :readonly="column.readonly"
+                style="width: 100%"
+              >
+                <el-option
+                  v-for="item in dict.type[column.config.optionsName]"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value"
+                >
+                </el-option>
+              </el-select>
+              <el-date-picker
+                v-else-if="column.type === 'DatePicker'"
+                v-model="params[column.key]"
+                :type="column.config.type"
+                :placeholder="column.placeholder"
+                :clearable="column.clearable"
+                :disabled="column.disabled"
+                :readonly="column.readonly"
+                :picker-options="column.pickerOptions"
+                style="width: 100%"
+              >
+              </el-date-picker>
+              <el-upload
+                v-else-if="column.type === 'Upload'"
+                :file-list="params[column.key]"
+                :disabled="column.disabled"
+                :readonly="column.readonly"
+                drag
+                action="https://jsonplaceholder.typicode.com/posts/"
+                multiple
+              >
+                <i class="el-icon-upload"></i>
+                <div class="el-upload__text">
+                  将文件拖到此处,或<em>点击上传</em>
+                </div>
+                <div class="el-upload__tip" slot="tip">
+                  只能上传jpg/png文件,且不超过500kb
+                </div>
+              </el-upload>
+              <el-input
+                v-else
+                v-model="params[column.key]"
+                :placeholder="column.placeholder"
+                :clearable="column.clearable"
+                :disabled="column.disabled"
+                :readonly="column.readonly"
+                style="width: 100%"
+              ></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-card>
+      <el-card
+        :body-style="{
+          padding: '20px',
+          display: 'flex',
+          'flex-wrap': 'wrap',
+          position: 'relative',
+        }"
+        style="margin: 10px"
+      >
+        <el-tabs v-model="tabName" style="width: 100%">
+          <el-tab-pane
+            v-for="(column, index) in tabColumns"
+            :key="index"
+            :label="column.title"
+            :name="column.key"
+          >
+            <el-table :data="params[column.key]" style="width: 100%">
+              <el-table-column
+                v-for="(cColumn, cIndex) in column.tableColumns"
+                :key="cIndex"
+                :prop="cColumn.key"
+                :label="cColumn.title"
+                :width="cColumn.width"
+              >
+                <template slot-scope="scope">
+                  <el-tag v-if="cColumn.key === 'index'">
+                    {{ scope.$index + 1 }}
+                  </el-tag>
+                  <el-input
+                    v-if="cColumn.type === 'Input'"
+                    v-model="scope.row[cColumn.key]"
+                    :placeholder="cColumn.placeholder"
+                    :clearable="cColumn.clearable"
+                    :disabled="cColumn.disabled"
+                    size="mini"
+                    style="width: 100%"
+                  ></el-input>
+                  <el-input-number
+                    v-if="cColumn.type === 'InputNumber'"
+                    v-model="scope.row[cColumn.key]"
+                    :controls-position="cColumn.config.controlsPosition"
+                    :placeholder="cColumn.placeholder"
+                    :clearable="cColumn.clearable"
+                    :disabled="cColumn.disabled"
+                    size="mini"
+                    style="width: 100%"
+                  ></el-input-number>
+                  <el-input
+                    v-if="column.type === 'InputDialog'"
+                    v-model="params[column.key]"
+                    :placeholder="column.placeholder"
+                    :clearable="column.clearable"
+                    :disabled="column.disabled"
+                    :readonly="column.readonly"
+                    style="width: 100%; cursor: pointer"
+                    @click.native.stop="openAsyncInputDialog(column, params)"
+                  >
+                    <template #suffix>
+                      <el-icon class="el-icon-thumb"></el-icon>
+                    </template>
+                  </el-input>
+                </template>
+              </el-table-column>
+              <el-table-column fixed="right" label="操作" width="120">
+                <template slot-scope="scope">
+                  <el-button
+                    @click.native.prevent="
+                      delTableRow(params[tabName], scope.$index)
+                    "
+                    type="text"
+                    size="small"
+                  >
+                    删行
+                  </el-button>
+                </template>
+              </el-table-column>
+            </el-table>
+          </el-tab-pane>
+        </el-tabs>
+        <el-row style="position: absolute; top: 20px; right: 20px">
+          <el-button size="mini" @click="addTableRow(params[tabName])"
+            >增行</el-button
+          >
+        </el-row>
+      </el-card>
+    </el-form>
+  </el-drawer>
+</template>

+ 1 - 1
src/views/purchase/purchase-task/add-purchase-task.vue

@@ -6,7 +6,7 @@ import {
   initRules,
   initParams,
   initComponents,
-} from "@/utils/init-something";
+} from "@/utils/init";
 import { initColumns } from "./config/add";
 
 export default {

+ 2 - 2
vue.config.js

@@ -37,7 +37,7 @@ module.exports = {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
         // target: `http://172.16.100.107:8080/drp-admin`, //测试
-        target: `http://test-sy.derom.com/drp-admin`, //测试
+        // target: `http://test-sy.derom.com/drp-admin`, //测试
         // target: `http://release-sy.derom.com/drp-admin`, //预发
         // target: `http://sy.derom.com/drp-admin`, //生产
         // target: `http://172.16.63.202:8000/drp-admin`, // D本地
@@ -45,7 +45,7 @@ module.exports = {
         // target: `http://172.16.13.152:8000/drp-admin`, //豪哥本地
         // target: `http://172.16.13.47:8000/drp-admin`, //石杨本地
         // target: `http://172.16.13.113:8000/drp-admin`, //DWT本地
-        // target: `http://172.16.13.77:8000/drp-admin`, //TQ本地
+        target: `http://172.16.13.77:8000/drp-admin`, //TQ本地
         changeOrigin: true,
         pathRewrite: {
           ["^" + process.env.VUE_APP_BASE_API]: "",