xiaodai2022 2 年 前
コミット
f7bebeff22
1 ファイル変更223 行追加162 行削除
  1. 223 162
      src/views/reportQuery/purchaseReport/components/table13.vue

+ 223 - 162
src/views/reportQuery/purchaseReport/components/table13.vue

@@ -1,134 +1,182 @@
 <template>
-    <div>
-      <ex-table
-        v-loading="loading"
-        :table="table"
-        :data="tableData"
-        :columns="table13"
-        :page="pageInfo"
-        :size="size"
-        @page-curr-change="handlePageChange"
-        @page-size-change="handleSizeChange"
-        @screen-reset="
-          pageInfo.curr = 1;
-          parmValue.page = 1;
-          searchList();
-        "
-        @screen-submit="
-          pageInfo.curr = 1;
-          parmValue.page = 1;
-          searchList();
-        "
-        @selection="selection_change"
-      >
-        <template #table-header="{}">
-          <div style="width: 100%">
-            <el-row style="padding: 0 0 0 80px">
-             
-               <el-col :span="6" style="width: 463px;">
-                <periodDatePickerActive
-                      :start="parmValue.start_date"
-                      :end="parmValue.end_date"
-                      :placeholder="'产品操作'"
-                      :width="'205px'"
-                      :size="searchSize"
-                      @timeReturned="time"
-                    />
-              </el-col>  
-              <el-col :span="4" style="width: 66px; float: right">       
-                <el-button type="primary" style="margin-left:30px;" @click="download" :size="searchSize"  class="fr">
-                    导出
-                </el-button>
-              </el-col>
-              <el-col :span="3" style="width: 66px; float: right">
-                <el-button
-                  :size="searchSize"
-                  type="primary"
-                  style="float: right; margin-left: 5px"
-                  @click="searchList"
-                >
-                  刷新
-                </el-button>
-              </el-col>
-              
-            </el-row>
-            <el-row style="padding: 10px 0 0 0" gutter="10">
-              <el-col :span="6" style="width: 240px">
-                <el-input
-                  clearable
-                  placeholder="采购维护人"
-                  v-model="parmValue.creater"
-                  maxlength="40"
-                  :size="searchSize"
-                  @blur="
-                    pageInfo.curr = 1;
-                    parmValue.page = 1;
-                    searchList();
-                  "
-                >
-                </el-input>
-              </el-col>
-              <el-col :span="6" style="width: 240px">
-                <el-input
-                  clearable
-                  placeholder="供应商名称"
-                  v-model="parmValue.supplier_name"
-                  maxlength="40"
-                  :size="searchSize"
-                  @blur="
-                    pageInfo.curr = 1;
-                    parmValue.page = 1;
-                    searchList();
-                  "
-                >
-                </el-input>
-              </el-col>
-              <el-col :span="4" style="width: 66px; float: right">
-                <el-button
-                  type="warning"
-                  class="fr"
-                  :size="searchSize"
-                  @click="restSearch"
-                >
-                  重置
-                </el-button>
-              </el-col>     
-            </el-row>
-          </div>
-       </template>
+  <div>
+    <ex-table
+      v-loading="loading"
+      :table="table"
+      :data="tableData"
+      :columns="table13"
+      :page="pageInfo"
+      :size="size"
+      @page-curr-change="handlePageChange"
+      @page-size-change="handleSizeChange"
+      @screen-reset="
+        pageInfo.curr = 1;
+        parmValue.page = 1;
+        searchList();
+      "
+      @screen-submit="
+        pageInfo.curr = 1;
+        parmValue.page = 1;
+        searchList();
+      "
+      @selection="selection_change"
+    >
+      <template #table-header="{}">
+        <div style="width: 100%">
+          <el-row style="padding: 0 0 0 80px">
+            <el-col :span="6" style="width: 463px">
+              <periodDatePickerActive
+                :start="parmValue.start_date"
+                :end="parmValue.end_date"
+                :placeholder="'产品操作'"
+                :width="'205px'"
+                :size="searchSize"
+                @timeReturned="time"
+              />
+            </el-col>
+            <el-col :span="4" style="width: 66px; float: right">
+              <el-button
+                type="primary"
+                style="margin-left: 30px"
+                @click="download"
+                :size="searchSize"
+                class="fr"
+              >
+                导出
+              </el-button>
+            </el-col>
+            <el-col :span="3" style="width: 66px; float: right">
+              <el-button
+                :size="searchSize"
+                type="primary"
+                style="float: right; margin-left: 5px"
+                @click="searchList"
+              >
+                刷新
+              </el-button>
+            </el-col>
+          </el-row>
+          <el-row style="padding: 10px 0 0 0" gutter="10">
+            <el-col :span="6" style="width: 240px">
+              <el-input
+                clearable
+                placeholder="采购维护人"
+                v-model="parmValue.creater"
+                maxlength="40"
+                :size="searchSize"
+                @blur="
+                  pageInfo.curr = 1;
+                  parmValue.page = 1;
+                  searchList();
+                "
+              >
+              </el-input>
+            </el-col>
+            <el-col :span="6" style="width: 240px">
+              <el-input
+                clearable
+                placeholder="供应商名称"
+                v-model="parmValue.supplier_name"
+                maxlength="40"
+                :size="searchSize"
+                @blur="
+                  pageInfo.curr = 1;
+                  parmValue.page = 1;
+                  searchList();
+                "
+              >
+              </el-input>
+            </el-col>
+            <el-col :span="4" style="width: 66px; float: right">
+              <el-button
+                type="warning"
+                class="fr"
+                :size="searchSize"
+                @click="restSearch"
+              >
+                重置
+              </el-button>
+            </el-col>
+          </el-row>
+        </div>
+      </template>
 
-        <template #operation="{ scope }">
-          <el-tooltip
-            effect="dark"
-            content="修改内容对比"
-            placement="top"
-          >
-            <i
-              class="el-icon-view tb-icon"
-              @click="dlgTable(scope.row)"
-            ></i>
-          </el-tooltip>
-        </template>
-      </ex-table>
+      <template #operation="{ scope }">
+        <el-tooltip effect="dark" content="修改内容对比" placement="top">
+          <i class="el-icon-view tb-icon" @click="dlgTable(scope.row)"></i>
+        </el-tooltip>
+      </template>
+    </ex-table>
 
-      <el-dialog title="修改差异" :visible.sync="dialogTableVisible" >
-        <h3 class="editTitle" style="margin:0px 0 30px 0;">修改前</h3>
-      <el-table :data="[editOld]"
-      :size="searchSize"
-      border
-      style="width: 100%;">
-        <el-table-column :minWidth="item.minWidth" :prop="item.prop" v-if="editOld[item.prop]" :label="item.label" v-for="(item,index) in editTable13" :key="index+item.prop"/>
-      </el-table>
-        <h3 class="editTitle_active" style="margin:30px 0;">修改后</h3>
-      <el-table :data="[editNew]" :size="searchSize"
-      border
-      style="width: 100%;">
-        <el-table-column :minWidth="item.minWidth" :prop="item.prop" v-if="editOld[item.prop]" :label="item.label" v-for="(item,index) in editTable13" :key="item.prop+index"/>
+    <el-dialog
+      title="产品修改差异对比"
+      :visible.sync="dialogTableVisible"
+      :center="true"
+      align="left"
+      top="3vh"
+      width="1040px"
+      :close-on-click-modal="false"
+      element-loading-text="拼命加载中"
+      element-loading-spinner="el-icon-loading"
+      element-loading-background="rgba(0, 0, 0, 0.8)"
+      @close="dialogTableVisible = false"
+    >
+      <el-table
+        :data="showData"
+        :size="searchSize"
+        border
+        stripe
+        max-height="750px"
+        style="width: 100%; margin: -20px 0 0"
+      >
+        <el-table-column
+          prop="key_name"
+          label="修改字段名称"
+          width="130px"
+          show-overflow-tooltip
+        />
+        <el-table-column
+          prop="key"
+          label="修改字段"
+          width="130px"
+          show-overflow-tooltip
+        />
+        <el-table-column prop="before" label="修改前" show-overflow-tooltip>
+          <template slot-scope="scope">
+            <div v-if="scope.row.key === 'good_img'">
+              <img
+                v-for="(si, sii) in scope.row.before"
+                :key="si + sii"
+                :src="si"
+                alt=""
+                class="fl"
+                v-viewer
+                style="width: 30px; height: 30px"
+              />
+            </div>
+
+            <div v-else>{{ scope.row.before }}</div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="after" label="修改后" show-overflow-tooltip>
+          <template slot-scope="scope">
+            <div v-if="scope.row.key === 'good_img'">
+              <img
+                v-for="(si, sii) in scope.row.after"
+                :key="si + sii"
+                :src="si"
+                alt=""
+                v-viewer
+                 class="fl"
+                style="width: 30px; height: 30px"
+              />
+            </div>
+            <div v-else>{{ scope.row.after }}</div>
+          </template>
+        </el-table-column>
       </el-table>
     </el-dialog>
-    </div>
-
-  
+  </div>
 </template>
    <script>
 import mixinPage from "@/mixins/elPaginationHandle";
@@ -136,39 +184,38 @@ import resToken from "@/mixins/resToken";
 import urlConfig from "@/apis/url-config";
 import asyncRequest from "@/apis/service/reportQuery/purchaseReport";
 import periodDatePickerActive from "../period-date-picker/main.vue";
-import { table13,editTable13} from "./columns";
+import { table13, editTable13 } from "./columns";
 import { mapGetters } from "vuex";
 
 export default {
   name: "purchaseOrder",
   mixins: [mixinPage, resToken],
   components: {
-    periodDatePickerActive
+    periodDatePickerActive,
   },
   computed: {
     ...mapGetters(["tablebtnSize", "searchSize", "size"]),
-    
   },
   data() {
     return {
-      editOld:{},
-      editNew:{},
-      dialogTableVisible:false,
+      editOld: {},
+      editNew: {},
+      dialogTableVisible: false,
       //选中数组
       changeList: [],
+      showData: [],
       //全局url
       fileUrl: urlConfig.baseURL,
       //loading
       loading: false,
       //请求参数集合
       parmValue: {
-        creater:"", //采购维护人
-        supplier_name:"", // 供应商名称
+        creater: "", //采购维护人
+        supplier_name: "", // 供应商名称
         start_date: "", //起始时间
         end_date: "", // 结束时间
         page: 1, // 页码
         size: 15, // 每页显示条数
-       
       },
       // 表格 - 数据集合
       tableData: [],
@@ -190,23 +237,38 @@ export default {
     };
   },
   mounted() {
-
     this.searchList();
   },
 
   methods: {
-    dlgTable(row){
-      this.dialogTableVisible = true;
-      this.editOld = row.before_info;
-      this.editNew = row.after_info;
+    dlgTable(row) {
+      this.showData = [];
+      const { before_info, after_info } = row;
+
+      let keyList = [];
+      for (let key in after_info) {
+        keyList.push(key);
+      }
 
-      var num = 0;
-      for(var i in this.editOld){
-        num++
+      for (let i = 0; i < keyList.length; i++) {
+        let model = {
+          key: keyList[i],
+          key_name:
+            (editTable13.find((s) => s.prop === keyList[i]) || {}).label ||
+            "--",
+          before: this.get_key_value(keyList[i], before_info),
+          after: this.get_key_value(keyList[i], after_info),
+        };
+        this.showData.push(model);
+      }
+      console.log(this.showData);
+      this.dialogTableVisible = true;
+    },
+    get_key_value(key, info) {
+      if (key === "good_img") {
+        return info[key] ? (info[key] || "").split(",") : [];
       }
-      console.log(num)
-      console.log(this.editOld) 
-      console.log(this.editNew)
+      return info[key];
     },
     //初始化http请求
     async searchList() {
@@ -220,7 +282,7 @@ export default {
       // return;
       this.loading = true;
       const res = await asyncRequest.reportchangeloglist(this.parmValue);
-      console.log(res)
+      console.log(res);
       if (res && res.code === 0 && res.data) {
         this.tableData = res.data.list;
         this.pageInfo.total = Number(res.data.count);
@@ -230,16 +292,15 @@ export default {
         this.tableData = [];
         this.pageInfo.total = 0;
         this.$message.warning(res.message);
-
       }
       this.loading = false;
     },
-   
+
     //重置
     restSearch() {
       this.parmValue = {
-        creater:"", //采购维护人
-        supplier_name:"", // 供应商名称
+        creater: "", //采购维护人
+        supplier_name: "", // 供应商名称
         start_date: "", //新建起始时间
         end_date: "", // 新建结束时间
         page: 1, // 页码
@@ -253,7 +314,7 @@ export default {
       };
       this.searchList();
     },
-    
+
     // 时间函数
     async time(e) {
       this.parmValue.start_date = e.startTime || "";
@@ -261,13 +322,13 @@ export default {
       await this.searchList();
     },
 
-     //选中触发函数
+    //选中触发函数
     selection_change(e) {
       const { list } = e;
       //选中的数组集合
       this.changeList = list.length > 0 ? JSON.parse(JSON.stringify(list)) : [];
     },
-    //导出文件 
+    //导出文件
     async download() {
       // if(this.changeList.length<=0){
       //   this.$message.warning("请选择有效数据")
@@ -276,16 +337,16 @@ export default {
       let start_date = new Date(this.parmValue.start_date).valueOf();
       let end_date = new Date(this.parmValue.end_date).valueOf();
       let flag = end_date - start_date > 30 * 24 * 60 * 60 * 1000;
-      if(this.parmValue.start_date != "" && this.parmValue.end_date != ""){
-        if(flag){
-          this.$message.warning("导出文件的时间区间不能超过30天")
+      if (this.parmValue.start_date != "" && this.parmValue.end_date != "") {
+        if (flag) {
+          this.$message.warning("导出文件的时间区间不能超过30天");
           return;
         }
-      }else{
-        this.$message.warning("请选择导出文件的时间区间")
+      } else {
+        this.$message.warning("请选择导出文件的时间区间");
         return;
       }
-      let model = JSON.parse(JSON.stringify(this.parmValue))
+      let model = JSON.parse(JSON.stringify(this.parmValue));
       // model.is_export = 1;
       if (!this.loading) {
         this.loading = true;
@@ -309,7 +370,7 @@ export default {
               let url = window.URL.createObjectURL(
                 new Blob([res.data], {
                   // type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
-                  type: httpType
+                  type: httpType,
                 })
               );
               let link = document.createElement("a");
@@ -345,7 +406,7 @@ export default {
 .purchaseOrder {
   // text-align: right;
 }
-/deep/ .el-dialog{
+/deep/ .el-dialog {
   width: 80%;
   // height: 50vh;
   min-width: 800px;