002201 2 ani în urmă
părinte
comite
5b0b1c0827

+ 1 - 11
src/utils/init/index.js

@@ -33,14 +33,4 @@ export const initRules = (prop) => {
   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 = () => ({ pageNum: 1, pageSize: 25, total: 0 });
+export const initPage = () => ({ pageNum: 1, pageSize: 10, total: 0 });

+ 27 - 6
src/views/purchase/contract/column.js

@@ -130,7 +130,7 @@ export const Columns = [
     inputType: "PopoverSelect",
     referName: "TAX_RATE_PARAM",
     dataMapping: {
-      invoiceTax: "name",
+      invoiceTax: "ntaxrate",
     },
     require: true,
   },
@@ -356,9 +356,8 @@ export const TabColumns = [
         inputType: "PopoverSelect",
         referName: "TAX_RATE_PARAM",
         dataMapping: {
-          tax: "name",
+          tax: "ntaxrate",
         },
-
         width: 200,
       },
       {
@@ -380,11 +379,33 @@ export const TabColumns = [
         width: 200,
         computed: (prop) => {
           const { qty, taxPrice } = prop;
-          return qty && taxPrice ? qty * taxPrice : null;
+          const taxMoney = (qty * taxPrice).toFixed(8);
+          return taxMoney === "NaN" ? null : taxMoney;
+        },
+      },
+      {
+        title: "无税单价",
+        key: "taxFreePrice",
+        inputType: "ComputedInput",
+        width: 200,
+        computed: (prop) => {
+          const { tax, taxPrice } = prop;
+          const newTax = tax === "0E-8" ? 0 : Number(tax) / 100;
+          const taxFreePrice = (taxPrice / (1 + newTax)).toFixed(8);
+          return taxFreePrice === "NaN" ? null : taxFreePrice;
+        },
+      },
+      {
+        title: "无税金额合计",
+        key: "taxFreeMoney",
+        inputType: "ComputedInput",
+        width: 200,
+        computed: (prop) => {
+          const { qty, taxFreePrice } = prop;
+          const taxFreeMoney = (qty * taxFreePrice).toFixed(8);
+          return taxFreeMoney === "NaN" ? null : taxFreeMoney;
         },
       },
-      { title: "无税单价", key: "taxFreePrice" },
-      { title: "无税金额合计", key: "taxFreeMoney", width: 200 },
       {
         title: "注册证号及备案凭证号",
         key: "registration",

+ 2 - 5
src/views/purchase/contract/delete/index.vue

@@ -15,14 +15,11 @@ export default {
         cancelButtonText: "取消",
         type: "info",
       })
-        .then(() => {
+        .then(async () => {
           try {
-            const { code, msg } = REMOVE(prop);
+            const { code } = await REMOVE(prop);
             if (code === 200) {
               this.$emit("success");
-              this.$notify.success({ title: msg });
-            } else {
-              this.$notify.warning({ title: msg });
             }
           } catch (err) {
             // catch

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

@@ -39,11 +39,19 @@ export default {
   },
   computed: {},
   watch: {
-    "params.contractType": function (newProp) {
-      this.tabColumns = TabColumns.filter((element) =>
-        newProp === "1" ? element.key !== "contractItemList" : element
-      );
-      this.tabName = this.tabColumns[0].key;
+    "params.contractType": {
+      handler: function (newProp) {
+        if (newProp === "1") {
+          this.params.contractItemList = [];
+          this.tabColumns = TabColumns.filter(
+            (element) => element.key !== "contractItemList"
+          );
+        } else {
+          this.tabColumns = TabColumns;
+        }
+        this.tabName = this.tabColumns[0].key;
+      },
+      immediate: true,
     },
   },
   methods: {
@@ -62,18 +70,16 @@ export default {
     async fetchItem(prop) {
       try {
         this.loading = true;
-        const { code, msg, data } = await ITEM(prop);
+        const { code, data } = await ITEM(prop);
         if (code === 200) {
           this.params = data;
-          this.$notify.success({ title: msg });
           this.tabName = this.tabColumns[0].key;
           this.fetchTable(this.params.code, this.tabName);
-        } else {
-          this.$notify.warning({ title: msg });
         }
       } catch (err) {
-        //
+        // catch
       } finally {
+        // finally
         this.loading = false;
       }
     },
@@ -81,16 +87,14 @@ export default {
     async fetchTable(prop, name) {
       try {
         this.loading = true;
-        const { code, msg, rows } = await TABLELIST({ contractId: prop }, name);
+        const { code, rows } = await TABLELIST({ contractId: prop }, name);
         if (code === 200) {
           this.params[name] = rows;
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
         }
       } catch (err) {
-        //
+        // catch
       } finally {
+        // finally
         this.loading = false;
       }
     },
@@ -103,16 +107,14 @@ export default {
     async rowDelete(prop, { row: { id }, $index }) {
       try {
         this.loading = true;
-        const { code, msg } = await TABLEROMOVE(id, prop);
+        const { code } = await TABLEROMOVE(id, prop);
         if (code === 200) {
           this.params[prop].splice($index, 1);
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
         }
       } catch (err) {
-        //
+        // catch
       } finally {
+        // finally
         this.loading = false;
       }
     },
@@ -125,7 +127,7 @@ export default {
             const createByName = this.params.buyerName;
             const updateById = this.$store.state.user.id;
             const updateByName = this.$store.state.user.name;
-            const { code, msg } = await EDIT({
+            const { code } = await EDIT({
               createById,
               createByName,
               updateById,
@@ -135,14 +137,11 @@ export default {
             if (code === 200) {
               this.hide();
               this.$emit("success");
-              this.$notify.success({ title: msg });
-            } else {
-              this.$notify.warning({ title: msg });
             }
           } catch (err) {
-            //
+            // catch
           } finally {
-            //
+            // finally
           }
         } else {
           return false;

+ 42 - 57
src/views/purchase/contract/index.vue

@@ -1,7 +1,7 @@
 <script>
 import { LIST } from "@/api/business/purchase/contract";
-import { Columns as TableColumns, SearchColumns } from "./column";
 import { initPage, initDicts, initParams } from "@/utils/init";
+import { Columns as TableColumns, SearchColumns } from "./column";
 export default {
   name: "PuchaseContract",
   dicts: initDicts(TableColumns),
@@ -21,12 +21,12 @@ export default {
       params: initParams(SearchColumns),
       tableData: [],
       tableColumns: TableColumns,
-      page: initPage(),
+      page: { pageNum: 1, pageSize: 10, total: 0 },
     };
   },
   computed: {},
   created() {
-    this.queryList(this.params, this.page);
+    this.useQuery(this.params, this.page);
   },
   methods: {
     //
@@ -43,69 +43,58 @@ export default {
           this.tableData = rows;
           this.page.total = total;
           this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
         }
       } catch (err) {
-        //
+        // catch
       } finally {
+        // finally
         this.loading = false;
       }
     },
-    // 查询操作
-    queryList(prop, page) {
+    // 查 
+    useQuery(prop, page) {
       this.fetchList(prop, page);
     },
-    // 重置操作
-    resetList() {
+    // 重 
+    useReset() {
       this.page = initPage();
       this.params = initParams(SearchColumns);
-      this.queryList(this.params, this.page);
-    },
-    // 页大小变
-    sizeChange(prop) {
-      this.page.pageSize = prop;
-      this.queryList(this.params, this.page);
+      this.useQuery(this.params, this.page);
     },
-    // 当前页变
-    currentChange(prop) {
-      this.page.pageNum = prop;
-      this.queryList(this.params, this.page);
-    },
-    //
+    // 新 增
     async useAdd() {
       const { open } = this.$refs.AddModel;
       await open();
     },
-    //
-    async useSee(prop) {
+    // 删 除
+    async useDelete(prop) {
       const { id } = prop;
-      const { open } = this.$refs.SeeModel;
+      const { open } = this.$refs.DeleteModel;
       await open(id);
     },
-    //
+    // 编 辑
     async useEdit(prop) {
       const { id } = prop;
       const { open } = this.$refs.EditModel;
       await open(id);
     },
-    //
+    // 明 细
+    async useSee(prop) {
+      const { id } = prop;
+      const { open } = this.$refs.SeeModel;
+      await open(id);
+    },
+    // 导 出
     async useExport(prop) {
       const { pageNum, pageSize } = this.page;
       const { open } = this.$refs.ExportModel;
       await open({ ...prop, pageNum, pageSize });
     },
-    //
+    // 导 入
     async useImport() {
       const { open } = this.$refs.ImportModel;
       await open();
     },
-    //
-    async useDelete(prop) {
-      const { id } = prop;
-      const { open } = this.$refs.DeleteModel;
-      await open(id);
-    },
   },
 };
 </script>
@@ -122,13 +111,13 @@ export default {
     :body-style="{ padding: 0 }"
   >
     <see-model ref="SeeModel"></see-model>
-    <add-model ref="AddModel" @success="resetList"></add-model>
-    <edit-model ref="EditModel" @success="queryList(params, page)"></edit-model>
+    <add-model ref="AddModel" @success="useReset"></add-model>
+    <edit-model ref="EditModel" @success="useQuery(params, page)"></edit-model>
     <export-model ref="ExportModel"></export-model>
     <import-model ref="ImportModel"></import-model>
     <delete-model
       ref="DeleteModel"
-      @success="queryList(params, page)"
+      @success="useQuery(params, page)"
     ></delete-model>
     <el-form
       :size="size"
@@ -148,29 +137,17 @@ export default {
             <el-input
               v-model="params[column.key]"
               :placeholder="column.placeholder"
-              @change="queryList(params, page)"
+              @change="useQuery(params, page)"
             ></el-input>
           </el-form-item>
         </el-col>
-        <el-col :span="6">
-          <el-form-item label-width="0">
-            <el-button
-              circle
-              :size="size"
-              icon="el-icon-search"
-              @click="queryList(params, page)"
-            ></el-button>
-            <el-button
-              circle
-              :size="size"
-              icon="el-icon-refresh"
-              @click="resetList"
-            ></el-button>
-          </el-form-item>
-        </el-col>
       </el-row>
     </el-form>
     <el-row style="padding: 0 20px">
+      <el-button :size="size" @click="useQuery(params, page)">
+        查 询
+      </el-button>
+      <el-button :size="size" @click="useReset"> 重 置 </el-button>
       <el-button :size="size" @click="useAdd"> 新 增 </el-button>
       <el-button :size="size" @click="useExport(params)"> 导 出 </el-button>
       <el-button :size="size" @click="useImport"> 导 入 </el-button>
@@ -196,22 +173,30 @@ export default {
             :value="scope.row[column.key]"
             :options="dict.type[column.referName]"
           />
+          <el-button
+            v-else-if="column.inputType === 'Upload'"
+            type="text"
+            size="small"
+            @click.native.prevent="useEdit(scope.row)"
+          >
+            点击查看
+          </el-button>
           <span v-else>{{ scope.row[column.key] }}</span>
         </template>
       </el-table-column>
       <el-table-column fixed="right" label="操作" width="120">
         <template slot-scope="scope">
           <el-button
-            @click.native.prevent="useEdit(scope.row)"
             type="text"
             size="small"
+            @click.native.prevent="useEdit(scope.row)"
           >
             编 辑
           </el-button>
           <el-button
-            @click.native.prevent="useDelete(scope.row)"
             type="text"
             size="small"
+            @click.native.prevent="useDelete(scope.row)"
           >
             删 除
           </el-button>
@@ -222,7 +207,7 @@ export default {
       :total="page.total"
       :page.sync="page.pageNum"
       :limit.sync="page.pageSize"
-      @pagination="queryList(params, page)"
+      @pagination="useQuery(params, page)"
     />
   </el-card>
 </template>