Browse Source

1,优化->删除了上传限制
2,优化->删除重复的上传文件名显示
3,优化->将之前传后台的key统一改为大写
4,修改->文件上传数组改为对象的形式(包含Key,Name,SystemId,CreateTime,Type)
5,增量的情况:
a,只选择单值信息,只走单值接口,(和维新确认,不会对别的数据造成影响)。
b,只选择上传附件,只走附件接口。
c,单值和附件同时操作,走两个接口
6,覆盖的情况:传输修改的数据。
7,ui细节->所上传的文件名称和单值信息名称统一颜色

shaun-sheep 5 years ago
parent
commit
771553ef82

+ 17 - 1
src/api/scan/request.js

@@ -1,5 +1,5 @@
 import fetch from './fetch'
-import { api, baseUrl, business, physics, venders, zone } from './config.js'
+import {api, baseUrl, business, physics, venders, zone} from './config.js'
 import http from './httpUtil'
 
 let arithmetic = '/arithmetic'
@@ -1302,6 +1302,22 @@ export function getEquipInSys(param, success) {
   http.postJson(url, param, success)
 }
 
+// 统计设备信息点与需采集数据占比
+export function gatherInfoPoint(param, success) {
+  let url = `${baseUrl}/equip-component/equip-query/gather-info-point`;
+  http.postJson(url, param, success)
+}
+
+// 统计设备信息点与总数据占比
+export function infoPoint(param, success) {
+  let url = `${baseUrl}/equip-component/equip-query/info-point`;
+  http.postJson(url, param, success)
+}
+// 统计系统信息点与需采集数据占比
+export function systemInfoPoint(param, success) {
+  let url = `${baseUrl}/equip-component/equip-query/system-info-point`;
+  http.postJson(url, param, success)
+}
 //根据条件查询统计数量
 export function countGeneralSys(param, success) {
     let url = `${baseUrl}/datacenter/general-system/count`;

+ 91 - 53
src/components/dialogs/list/batchDialog.vue

@@ -1,9 +1,9 @@
 <template>
   <el-dialog
-        title="批量维护信息点"
-        :visible.sync="batchDialog"
-        class="batchContainer"
-    >
+      title="批量维护信息点"
+      :visible.sync="batchDialog"
+      class="batchContainer"
+  >
     <el-steps
         :active="active"
         align-center
@@ -68,7 +68,10 @@
             > <!--设备文档-->
               {{information.archive.name}}
             </el-checkbox>
-            <span v-for="item in information.archive.Archive">{{item | filterImgName}}</span>
+            <span
+                class="text-color"
+                v-for="item in information.archive.Archive"
+            >{{item.Name | filterImgName}}</span>
           </p>
           <p>
             <el-checkbox
@@ -77,7 +80,10 @@
             ><!--安装质检报告-->
               {{information.checkReport.name}}
             </el-checkbox>
-            <span v-for="item in information.checkReport.CheckReport">{{item | filterImgName}}</span>
+            <span
+                class="text-color"
+                v-for="item in information.checkReport.CheckReport"
+            >{{item.Name | filterImgName}}</span>
 
           </p>
           <p>
@@ -87,7 +93,10 @@
             ><!--设备图纸-->
               {{information.drawing.name}}
             </el-checkbox>
-            <span v-for="item in information.drawing.Drawing">{{item.key | filterImgName}}</span>
+            <span
+                class="text-color"
+                v-for="item in information.drawing.Drawing"
+            >{{item.Key | filterImgName}}</span>
 
           </p>
           <p>
@@ -98,9 +107,10 @@
               {{information.installDrawing.name}}
             </el-checkbox>
             <span
-                v-for="item in information.installDrawing.InstallDrawing">{{item.key | filterImgName}}</span>
+                class="text-color"
+                v-for="item in information.installDrawing.InstallDrawing"
+            >{{item.Key | filterImgName}}</span>
           </p>
-
           <p>
             <el-checkbox
                 v-model="videoModel.installPic"
@@ -108,7 +118,10 @@
             ><!--安装照片-->
               {{information.installPic.name}}
             </el-checkbox>
-            <span v-for="item in information.installPic.InstallPic">{{item.key | filterImgName}}</span>
+            <span
+                class="text-color"
+                v-for="item in information.installPic.InstallPic"
+            >{{item.Key | filterImgName}}</span>
           </p>
           <p>
             <el-checkbox
@@ -117,7 +130,10 @@
             ><!--保险文件-->
               {{information.insuranceFile.name}}
             </el-checkbox>
-            <span v-for="item in information.insuranceFile.InsuranceFile">{{item | filterImgName}}</span>
+            <span
+                class="text-color"
+                v-for="item in information.insuranceFile.InsuranceFile"
+            >{{item.Name | filterImgName}}</span>
 
           </p>
           <p>
@@ -127,7 +143,10 @@
             ><!--设备照片-->
               {{information.pic.name}}
             </el-checkbox>
-            <span v-for="item in information.pic.Pic">{{item.key | filterImgName}}</span>
+            <span
+                class="text-color"
+                v-for="item in information.pic.Pic"
+            >{{item.Key | filterImgName}}</span>
           </p>
           <p>
             <el-checkbox
@@ -135,7 +154,10 @@
                 @change="multiple('nameplate')"><!--设备铭牌照片-->
               {{information.nameplate.name}}
             </el-checkbox>
-            <span v-for="item in information.nameplate.Nameplate">{{item.key | filterImgName}}</span>
+            <span
+                class="text-color"
+                v-for="item in information.nameplate.Nameplate"
+            >{{item.Key | filterImgName}}</span>
           </p>
         </div>
       </section>
@@ -253,7 +275,7 @@
       information() {
         return this.information
       },
-    
+
     },
     computed: {
       newFirm() {
@@ -304,13 +326,13 @@
         //   });
         //   return false
         // }
-      let fillIn = this.onlySelect.some(i=>!i.info)
-        if(fillIn) {
-            this.$message({
-              message: '请填写勾选信息',
-              type: 'warning'
-            });
-            return false
+        let fillIn = this.onlySelect.some(i => !i.info)
+        if (fillIn) {
+          this.$message({
+            message: '请填写勾选信息',
+            type: 'warning'
+          });
+          return false
         }
         // if (!this.deviceList.length) { //对单项全选进行过滤
         //   this.$message({
@@ -374,7 +396,7 @@
         // this.filterList 单选数组,取到需要数据
         // 过滤数组,取对象
         this.checkedCities.filter(item => item.num === 2).forEach(i => { //型号
-          if(i.info) {
+          if (i.info) {
             let {venderName, brandName, Specification, venderId, brandId, specificationId} = i.info
             single.EquipManufactor = {
               Manufacturer: venderName,
@@ -387,38 +409,46 @@
           }
         })
         this.checkedCities.filter(item => item.num === 8).forEach(i => {  //供应商8
-         if(i.info) {
-           let {website, name, venderId} = i.info
-           single.SupplyPurchase = {
-             SupplierWeb: website,
-             Supplier: name,
-
-           }
-           Id.DPSupplierID = venderId
-         }
+          if (i.info) {
+            let {website, name, venderId} = i.info
+            single.SupplyPurchase = {
+              SupplierWeb: website,
+              Supplier: name,
+
+            }
+            Id.DPSupplierID = venderId
+          }
         })
         this.checkedCities.filter(item => item.num === 35).forEach(i => {  //维修商
-         if(i.info) {
-           let {name, venderId} = i.info
-           single.OperationMainte = {
-             Maintainer: name
-           }
-           Id.DPMaintainerID = venderId
-         }
-        })
-        this.checkedCities.filter(item => item.num === 42).forEach(i => {  //保险
-         if(i.info) {
-           let {website, name, venderId} = i.info
-           single.InsuranceDoc = {
-             Insurer: name,
-             InsurerWeb: website,
-             InsuranceFile: this.information.insuranceFile.InsuranceFile.length ? this.information.insuranceFile.InsuranceFile : undefined
-
-           }
-
-           Id.DPInsurerID = venderId
-         }
+          if (i.info) {
+            let {name, venderId} = i.info
+            single.OperationMainte = {
+              Maintainer: name
+            }
+            Id.DPMaintainerID = venderId
+          }
         })
+        let insurance = this.checkedCities.filter(item => item.num === 42)
+        if (insurance.length) {
+          insurance.forEach(i => {  //保险
+            if (i.info) {
+              let {website, name, venderId} = i.info
+              single.InsuranceDoc = {
+                Insurer: name,
+                InsurerWeb: website,
+                InsuranceFile: this.information.insuranceFile.InsuranceFile.length && this.radio === 2 ? this.information.insuranceFile.InsuranceFile : undefined
+              }
+              Id.DPInsurerID = venderId
+            }
+          })
+        } else {
+          if (this.radio === 2) {
+            single.InsuranceDoc = {
+              InsuranceFile: this.information.insuranceFile.InsuranceFile.length ? this.information.insuranceFile.InsuranceFile : undefined
+            }
+          }
+        }
+
         // this.information 多选信息
         let {archive, checkReport, drawing, installDrawing, installPic, insuranceFile, nameplate, pic} = this.information
         let multiple = {
@@ -447,12 +477,16 @@
 
           }))
           //    2:多选数据
+          let {InsuranceDoc, PhotoDoc, Siteinstall} = multiple
           let arr2 = this.deepCopy(arr).map(item => ({
             ...item,
-            LedgerParam: {...multiple}
+            ...InsuranceDoc,
+            ...PhotoDoc,
+            ...Siteinstall
+            // LedgerParam: {...multiple}
           }))
           this.$emit('upDataDevice', 1, arr1, arr2)
-          
+
         }
         if (this.radio === 2) {
           let {InsuranceDoc, ...multiples} = multiple
@@ -531,6 +565,10 @@
       margin: 2% 0;
     }
 
+    .text-color {
+      color: #409EFF
+    }
+
     .el-checkbox-group {
       display: flex;
       justify-content: space-between;

+ 149 - 143
src/components/dialogs/list/picDialog.vue

@@ -3,160 +3,166 @@
 -->
 
 <template>
-    <el-dialog title="上传图片" :visible.sync="dialog.pic" width="500px;">
-        <div style="max-height:500px;overflow-y:auto;">
-            <div>
-                <h3>设备图片</h3>
-                <upload-imgs
-                    :readOnly="read"
-                    :keysArr="picArrs"
-                    @change="imageItem"
-                    max="6"
-                />
-            </div>
-            <div>
-                <h3>视频</h3>
-                <upload-imgs
-                    :accept="'video/*'"
-                    type="video"
-                    :keysArr="videoArr"
-                    @change="videoItem"
-                    :videoPicArr="videoPicArr"
-                    max="2"
-                    :readOnly="read"
-                />
-            </div>
-        </div>
-    </el-dialog>
+  <el-dialog title="上传图片" :visible.sync="dialog.pic" width="500px;">
+    <div style="max-height:500px;overflow-y:auto;">
+      <div>
+        <h3>设备图片</h3>
+        <upload-imgs
+            :readOnly="read"
+            :keysArr="picArrs"
+            @change="imageItem"
+
+        />
+      </div>
+      <!--          max="6"-->
+      <div>
+        <h3>视频</h3>
+        <upload-imgs
+            :accept="'video/*'"
+            type="video"
+            :keysArr="videoArr"
+            @change="videoItem"
+            :videoPicArr="videoPicArr"
+            :readOnly="read"
+        />
+        <!--              max="2"-->
+      </div>
+    </div>
+  </el-dialog>
 </template>
 <script>
-    import uploadImgs from "@/components/ledger/lib/uploadImgsName";
+  import uploadImgs from "@/components/ledger/lib/uploadImgsName";
 
-    export default {
-        components: {
-            uploadImgs
-        },
-        props: {
-            dialog: {
-                type: Object,
-                default: function () {
-                    return {
-                        pic: true
-                    };
-                }
-            },
-            keysArr: {
-                type: Array,
-                default: function () {
-                    return []
-                }
-            },
-            read: {
-                type: Boolean,
-                default: false
-            },
-            firmDataType: {
-                type: String
-            },
-            information: {
-                type: Object
-            },
-            infoType: {
-                type: String
-            }
-        },
-        data() {
-            return {
-                picArrs: [],
-                panoramaArr: [],
-                videoArr: [],
-                videoPicArr: [],
-                changeKeys: []
-            };
-        },
-        created() {
-        },
-        mounted() {
-        },
-        methods: {
-            imageItem(images) {
-                this.picArrs = images
-                this.change()
-            },
+  export default {
+    components: {
+      uploadImgs
+    },
+    props: {
+      dialog: {
+        type: Object,
+        default: function () {
+          return {
+            pic: true
+          };
+        }
+      },
+      keysArr: {
+        type: Array,
+        default: function () {
+          return []
+        }
+      },
+      read: {
+        type: Boolean,
+        default: false
+      },
+      firmDataType: {
+        type: String
+      },
+      information: {
+        type: Object
+      },
+      infoType: {
+        type: String
+      }
+    },
+    data() {
+      return {
+        picArrs: [],
+        panoramaArr: [],
+        videoArr: [],
+        videoPicArr: [],
+        changeKeys: []
+      };
+    },
+    created() {
+    },
+    mounted() {
+    },
+    methods: {
+      imageItem(images) {
+        this.picArrs = images
+        this.change()
+      },
 
-            panoramaItem(images) {
-                this.panoramaArr = images
-                this.change()
-            },
+      panoramaItem(images) {
+        this.panoramaArr = images
+        this.change()
+      },
 
-            videoItem(videos, pe, pics) {
-                this.videoArr = videos
-                this.videoPicArr = pics
-                this.change()
-            },
+      videoItem(videos, pe, pics) {
+        this.videoArr = videos
+        this.videoPicArr = pics
+        this.change()
+      },
 
-            change() {
-                //   let picsArr = this.getArr(this.picArrs, "设备图片", "image")
-                //   let videos = this.getArr(this.videoArr, "视频", "video")
-                //   let videoPics = this.getArr(this.videoPicArr, "视频资料", "image_video")
-                //   let panoramas = this.getArr(this.panoramaArr, "全景照片", "panorama")
-                let picsArr = this.picArrs
-                let videos = this.videoArr
-                let videoPics = this.videoPicArr
-                let panoramas = this.panoramaArr
-                this.changeKeys = picsArr.concat(videos).concat(videoPics).concat(panoramas)
-                if (this.firmDataType === 'dialog') {
-                    this.information.pic.Pic = this.changeKeys
-                    this.$emit("change",this.information,this.firmDataType)
-                } else {
-                    this.$emit("change", this.changeKeys)
+      change() {
+        //   let picsArr = this.getArr(this.picArrs, "设备图片", "image")
+        //   let videos = this.getArr(this.videoArr, "视频", "video")
+        //   let videoPics = this.getArr(this.videoPicArr, "视频资料", "image_video")
+        //   let panoramas = this.getArr(this.panoramaArr, "全景照片", "panorama")
+        let picsArr = this.picArrs
+        let videos = this.videoArr
+        let videoPics = this.videoPicArr
+        let panoramas = this.panoramaArr
+        this.changeKeys = picsArr.concat(videos).concat(videoPics).concat(panoramas)
+        if (this.firmDataType === 'dialog') {
+          this.information.pic.Pic = this.changeKeys
+          this.$emit("change", this.information, this.firmDataType)
+        } else {
+          this.$emit("change", this.changeKeys)
 
-                }
-            },
+        }
+      },
 
-            getArr(arr, name, type) {
-                return arr.map(item => {
-                    return {"systemId": "dataPlatform", "name": name, "type": type, "key": item}
-                })
-            },
+      getArr(arr, name, type) {
+        return arr.map(item => {
+          return {
+            "SystemId": "dataPlatform",
+            "Name": name,
+            "Type": type,
+            "Key": item,
+          }
+        })
+      },
 
-            //将父组件传来的数据进行分组
-            fatherTochild() {
-                this.panoramaArr = []
-                this.videoArr = []
-                this.videoPicArr = []
-                this.picArrs = []
-                if (this.keysArr instanceof Array) {
-                    this.keysArr.map(item => {
-                        if (item.type == 'panorama') {
-                            this.panoramaArr.push(item)
-                        } else if (item.type == "video") {
-                            this.videoArr.push(item)
-                        } else if (item.type == 'image_video') {
-                            this.videoPicArr.push(item)
-                        } else {
-                            this.picArrs.push(item)
-                        }
-                    })
-                } else {
-                    this.panoramaArr = []
-                    this.videoArr = []
-                    this.videoPicArr = []
-                    this.picArrs = []
-                }
-            }
-        },
-        watch: {
-            dialog: {
-                deep: true,
-                handler: function () {
-                    if (this.dialog.pic) {
-                        this.fatherTochild()
-                    }
-                }
+      //将父组件传来的数据进行分组
+      fatherTochild() {
+        this.panoramaArr = []
+        this.videoArr = []
+        this.videoPicArr = []
+        this.picArrs = []
+        if (this.keysArr instanceof Array) {
+          this.keysArr.map(item => {
+            if (item.type == 'panorama') {
+              this.panoramaArr.push(item)
+            } else if (item.type == "video") {
+              this.videoArr.push(item)
+            } else if (item.type == 'image_video') {
+              this.videoPicArr.push(item)
+            } else {
+              this.picArrs.push(item)
             }
+          })
+        } else {
+          this.panoramaArr = []
+          this.videoArr = []
+          this.videoPicArr = []
+          this.picArrs = []
+        }
+      }
+    },
+    watch: {
+      dialog: {
+        deep: true,
+        handler: function () {
+          if (this.dialog.pic) {
+            this.fatherTochild()
+          }
         }
-    };
+      }
+    }
+  };
 </script>
 <style>
 </style>

File diff suppressed because it is too large
+ 1178 - 1146
src/components/ledger/handsontables/device.vue


+ 229 - 223
src/components/ledger/lib/uploadFiles.vue

@@ -8,241 +8,247 @@
   isShow: 图片的显示
  -->
 <template>
-    <div id="saga-upload">
-        <div id="uploadFile">
-
-            <el-upload
-                v-if="filesArr.length < max"
-                class="upload-file"
-                action
-                :show-file-list="showFileList"
-                :http-request="uploadAndSubmit"
-                drag
-            >
-
-                <el-button
-                    size="small"
-                    type="primary"
-                    v-if="!readOnly"
-                >点击上传
-                </el-button>
-                <div
-                    slot="tip"
-                    class="el-upload__tip"
-                    v-if="!readOnly"
-                >请上传文件
-                </div>
-            </el-upload>
-
-            <div
-                v-show="item && filesArr.length"
-                v-for="(item,index) in filesArr"
-            >
-                <el-button
-                    type="text"
-                    @click="download(item)"
-                >{{delFile(item)}}
-                </el-button>
-                <i
-                    v-if="!readOnly"
-                    class="el-icon-close delete-icon"
-                    style="margin-left:10px; cursor:pointer"
-                    @click="deleteFile(index,item)"
-                ></i>
-            </div>
+  <div id="saga-upload">
+    <div id="uploadFile">
+      <el-upload
+          class="upload-file"
+          action
+          :show-file-list="false"
+          :http-request="uploadAndSubmit"
+          drag
+      >
+        <el-button
+            size="small"
+            type="primary"
+            v-if="!readOnly "
+        >点击上传
+        </el-button>
+        <div
+            slot="tip"
+            class="el-upload__tip"
+            v-if="!readOnly"
+        >请上传文件
         </div>
+      </el-upload>
+
+      <div
+          v-show="item && filesArr.length"
+          v-for="(item,index) in filesArr"
+      >
+        <el-button
+            type="text"
+            @click="download(item.Key)"
+        >
+          {{delFile(item.Name)}}
+        </el-button>
+        <i
+            v-if="!readOnly"
+            class="el-icon-close delete-icon"
+            style="margin-left:10px; cursor:pointer"
+            @click="deleteFile(index,item)"
+        ></i>
+      </div>
+    </div>
   </div>
 </template>
 
 <script>
-    import tools from "@/utils/scan/tools";
-
-    export default {
-        props: {
-            keysArr: {
-                type: [Array, String],
-                default: function () {
-                    return []
-                }
-            },
-            readOnly: {
-                type: Boolean,
-                default: false
-            },
-            max: {
-                type: [Number, String],
-                default: 6
-            },
-            defined: null,
-            firmDataType: {
-                type: String
-            },
-            information: {
-                type: Object
-            },
-            infoType: {
-                type: String
-            }
-        },
-        data() {
-            return {
-                filesArr: [],
-                isShow: Boolean
-            };
-        },
-        created() {
-            let type = typeof (this.keysArr)
-            this.fileFalg()
-            // this.resetFile()
-        },
-        computed: {
-            showFileList() {
-                if (this.firmDataType === 'dialog') {
-                    this.isShow = false
+  import tools from "@/utils/scan/tools";
+
+  export default {
+    props: {
+      keysArr: {
+        type: [Array, String],
+        default: function () {
+          return []
+        }
+      },
+      readOnly: {
+        type: Boolean,
+        default: false
+      },
+      max: {
+        type: [Number, String],
+        default: 6
+      },
+      defined: null,
+      firmDataType: {
+        type: String
+      },
+      information: {
+        type: Object
+      },
+      infoType: {
+        type: String
+      }
+    },
+    data() {
+      return {
+        filesArr: [],
+        isShow: Boolean
+      };
+    },
+    created() {
+      // let type = typeof (this.keysArr)
+      this.fileFalg()
+      // this.resetFile()
+    },
+    computed: {
+      showFileList() {
+        if (this.firmDataType === 'dialog') {
+          this.isShow = false
+        } else {
+          this.isShow = true
+        }
+        return this.isShow
+      }
+    },
+    methods: {
+      //判断是否为空
+      fileFalg() {
+        let type = typeof (this.keysArr)
+        if (type == 'string') {
+          this.filesArr = [this.keysArr]
+
+        } else {
+          this.filesArr = tools.deepCopy(this.keysArr)
+        }
+        this.filesArr = tools.deepCopy(this.keysArr)
+        if (!this.keysArr) {
+          this.filesArr = []
+        }
+      },
+      //处理地址
+      delFile(name) {
+        return name.length > 20 ? name.substring(0, 20) + "..." : name
+      },
+
+      resetFile() {
+        this.filesArr = []
+      },
+
+
+      //点击下载
+      download(key) {
+        console.log(key)
+        window.open("/image-service/common/file_get/" + key + "?systemId=dataPlatform")
+      },
+
+      //删除图片
+      deleteFile(i, key) {
+        this.filesArr.splice(i, 1);
+        this.$emit("change", this.filesArr, this.defined);
+      },
+
+      //上传
+      uploadAndSubmit(item) {
+        // var form = document.forms["demoForm"];
+
+        // if (form["file"].files.length > 0) {
+        // 寻找表单域中的 <input type="file" ... /> 标签
+        // var file = form["file"].files[0];
+
+        let file = item.file;
+        // try sending
+        let reader = new FileReader();
+
+        let vm = this;
+
+        let fileType = file.name.split(".");
+        let type = fileType[fileType.length - 1];
+        let key = "&key=" + fileType[0] + file.uid + "." + type
+        let CreateTime = tools.formatDate(new Date(file.lastModified))
+        reader.onloadstart = function () {
+          // 这个事件在读取开始时触发
+        };
+        reader.onprogress = function (p) {
+          // 这个事件在读取进行中定时触发
+        };
+
+        reader.onload = function () {
+          // 这个事件在读取成功结束后触发
+        };
+        reader.onloadend = function () {
+          // 这个事件在读取结束后,无论成功或者失败都会触发
+          if (reader.error) {
+          } else {
+            // document.getElementById("bytesRead").textContent = file.size;
+            // 构造 XMLHttpRequest 对象,发送文件 Binary 数据
+            var xhr = new XMLHttpRequest();
+            xhr.open(
+              /* method */
+              "POST",
+              /* target url */
+              "/image-service/common/file_upload?systemId=dataPlatform&secret=9e0891a7a8c8e885&overwrite=true" + key
+              /*, async, default to true */
+            );
+            //xhr.overrideMimeType("application/octet-stream");
+            xhr.send(reader.result);
+            xhr.onreadystatechange = function () {
+              if (xhr.readyState == 4) {
+                console.log(xhr)
+                if (xhr.status == 200) {
+                  let fileObject = {
+                    Key: key.split("=")[1],
+                    Type: type,
+                    Name: file.name,
+                    CreateTime,
+                    SystemId: 'dataPlatform'
+                  }
+                  vm.filesArr.push(fileObject);
+                  vm.$emit("change", vm.filesArr, vm.defined);
                 } else {
-                    this.isShow = true
+                  this.$message.error(res.data.ResultMsg)
                 }
-                return this.isShow
-            }
-        },
-        methods: {
-            //判断是否为空
-            fileFalg() {
-                let type = typeof (this.keysArr)
-                if (type == 'string') {
-                    this.filesArr = [this.keysArr]
+              }
+            };
+          }
+        };
+        reader.readAsArrayBuffer(file);
+      }
+    },
+    watch: {
+      keysArr: function (val) {
+        this.fileFalg()
+      }
+    }
+  };
+</script>
 
-                } else {
-                    this.filesArr = tools.deepCopy(this.keysArr)
+<style lang="less">
+  #saga-upload {
+    .dill-image {
+      position: absolute;
+      right: 0px;
+      top: 0px;
+      font-size: 20px;
+    }
 
-                }
+    .el-upload-dragger {
+      width: 180px;
+      height: 180px;
+    }
 
-                if (!this.keysArr) {
-                    this.filesArr = []
-                }
-            },
-            //处理地址
-            delFile(name) {
-                return name.length > 20 ? name.substring(0, 20) + "..." : name
-            },
-
-            resetFile() {
-                this.filesArr = []
-            },
-
-
-            //点击下载
-            download(key) {
-                console.log(key)
-                window.open("/image-service/common/file_get/" + key + "?systemId=dataPlatform")
-            },
-
-            //删除图片
-            deleteFile(i, key) {
-                this.filesArr.splice(i, 1);
-                this.$emit("change", this.filesArr, this.defined);
-            },
-
-            //上传
-            uploadAndSubmit(item) {
-                // var form = document.forms["demoForm"];
-
-                // if (form["file"].files.length > 0) {
-                // 寻找表单域中的 <input type="file" ... /> 标签
-                // var file = form["file"].files[0];
-
-                let file = item.file;
-                // try sending
-                let reader = new FileReader();
-
-                let vm = this;
-
-                let fileType = file.name.split(".");
-                let type = fileType[fileType.length - 1];
-                let key = "&key=" + fileType[0] + file.uid + "." + type
-
-                reader.onloadstart = function () {
-                    // 这个事件在读取开始时触发
-                };
-                reader.onprogress = function (p) {
-                    // 这个事件在读取进行中定时触发
-                };
-
-                reader.onload = function () {
-                    // 这个事件在读取成功结束后触发
-                };
-                reader.onloadend = function () {
-                    // 这个事件在读取结束后,无论成功或者失败都会触发
-                    if (reader.error) {
-                    } else {
-                        // document.getElementById("bytesRead").textContent = file.size;
-                        // 构造 XMLHttpRequest 对象,发送文件 Binary 数据
-                        var xhr = new XMLHttpRequest();
-                        xhr.open(
-                            /* method */
-                            "POST",
-                            /* target url */
-                            "/image-service/common/file_upload?systemId=dataPlatform&secret=9e0891a7a8c8e885&overwrite=true" + key
-                            /*, async, default to true */
-                        );
-                        //xhr.overrideMimeType("application/octet-stream");
-                        xhr.send(reader.result);
-                        xhr.onreadystatechange = function () {
-                            if (xhr.readyState == 4) {
-                                console.log(xhr)
-                                if (xhr.status == 200) {
-                                    vm.filesArr.push(
-                                        key.split("=")[1]
-                                    );
-                                    vm.$emit("change", vm.filesArr, vm.defined);
-                                } else {
-                                    this.$message.error(res.data.ResultMsg)
-                                }
-                            }
-                        };
-                    }
-                };
-                reader.readAsArrayBuffer(file);
-            }
-        },
-        watch: {
-            keysArr: function (val) {
-                this.fileFalg()
-            }
-  }
-};
-</script>
+    img {
+      position: absolute;
+      top: 0;
+      bottom: 0;
+      left: 0;
+      right: 0;
+      width: 100%;
+      height: 100%;
+    }
 
-<style lang="less">
-#saga-upload {
-  .dill-image {
-    position: absolute;
-    right: 0px;
-    top: 0px;
-    font-size: 20px;
-  }
-  .el-upload-dragger {
-    width: 180px;
-    height: 180px;
-  }
-  img {
-    position: absolute;
-    top: 0;
-    bottom: 0;
-    left: 0;
-    right: 0;
-    width: 100%;
-    height: 100%;
-  }
-  #uploadFile {
-    .upload-file {
-      overflow: hidden;
-      .el-upload-dragger {
-        width: inherit;
-        height: inherit;
-        border: none;
+    #uploadFile {
+      .upload-file {
+        overflow: hidden;
+
+        .el-upload-dragger {
+          width: inherit;
+          height: inherit;
+          border: none;
+        }
       }
     }
   }
-}
 </style>

+ 290 - 279
src/components/ledger/lib/uploadImgs.vue

@@ -9,26 +9,27 @@
     <div class="saga-upload-images">
       <div v-if="type != 'video'" class="point-image" v-for="(item,index) in imagesArr">
         <i v-if="!readOnly" class="el-icon-delete" @click="delImage(index,item)"></i>
-        <img :src="imageGetUrl + '&key=' +item.key" @click="lookImg" alt v-load>
+        <img :src="imageGetUrl + '&key=' +item.Key" @click="lookImg" alt v-load>
       </div>
       <div v-if="type == 'video'" class="point-image" v-for="(item,index) in imagesArr">
         <i v-if="!readOnly" class="el-icon-delete" @click="delImage(index,item)"></i>
         <video
-          width="100%"
-          height="100%;"
-          :src="imageGetUrl + '&key=' +item.key"
-          controls="controls"
-        >您的浏览器不支持 video 标签。</video>
+            width="100%"
+            height="100%;"
+            :src="imageGetUrl + '&key=' +item.Key"
+            controls="controls"
+        >您的浏览器不支持 video 标签。
+        </video>
       </div>
-      <div v-if="!readOnly && imagesArr.length < max" style="float:left;">
+      <div v-if="!readOnly" style="float:left;">
         <el-upload
-          class="avatar-uploader"
-          :http-request="uploadAndSubmit"
-          :show-file-list="false"
-          :accept="accept"
-          action
-          drag
-          style="position: relation"
+            class="avatar-uploader"
+            :http-request="uploadAndSubmit"
+            :show-file-list="false"
+            :accept="accept"
+            action
+            drag
+            style="position: relative"
         >
           <i class="el-icon-plus avatar-uploader-icon"></i>
         </el-upload>
@@ -39,301 +40,311 @@
   </div>
 </template>
 <script>
-import tools from "@/utils/scan/tools";
-import detailsDialog from "@/components/business_space/lib/detailsDia"
-export default {
-  components: {
-    detailsDialog
-  },
-  props: {
-    keysArr: {
-      type: [Array, String]
-    },
-    readOnly: {
-      type: Boolean,
-      default: false
-    },
-    max: {
-      type: [Number, String],
-      default: 6
-    },
-    accept: {
-      type: String,
-      default: "image/*"
-    },
-    type: {
-      type: String,
-      default: "image"
-    },
-    defined: null,
-    videoPicArr: {
-      type: Array,
-      default: function () {
-        return []
-      }
-    }
-  },
-  data() {
-    return {
-      baseUrl: "",
-      imageGetUrl: "/image-service/common/image_get?systemId=dataPlatform",
-      imageUploadUrl: "/image-service/common/image_upload?systemId=dataPlatform&secret=9e0891a7a8c8e885&overwrite=true",
-      imagesArr: [],
-      iframeSrc: "",
-      dialog: {
-        details: false
-      }
-    };
-  },
-  created() {
-    this.imageFalg();
-  },
-  methods: {
-    //判断是否为空
-    imageFalg() {
-      let type = typeof this.keysArr;
-      console.log(this.keysArr)
-      if (type == "string") {
-        this.imagesArr = [this.keysArr];
-      } else {
-        this.imagesArr = tools.deepCopy(this.keysArr);
-      }
+  import tools from "@/utils/scan/tools";
+  import detailsDialog from "@/components/business_space/lib/detailsDia"
 
-      if (!this.keysArr) {
-        this.imagesArr = [];
+  export default {
+    components: {
+      detailsDialog
+    },
+    props: {
+      keysArr: {
+        type: [Array, String]
+      },
+      readOnly: {
+        type: Boolean,
+        default: false
+      },
+      max: {
+        type: [Number, String],
+        default: 6
+      },
+      accept: {
+        type: String,
+        default: "image/*"
+      },
+      type: {
+        type: String,
+        default: "image"
+      },
+      defined: null,
+      videoPicArr: {
+        type: Array,
+        default: function () {
+          return []
+        }
       }
     },
-    //查看图片
-    lookImg() {
-      this.dialog.details = true
-      this.iframeSrc = process.env.BASE_URL + ":8890/photo-View.html"
+    data() {
+      return {
+        baseUrl: "",
+        imageGetUrl: "/image-service/common/image_get?systemId=dataPlatform",
+        imageUploadUrl: "/image-service/common/image_upload?systemId=dataPlatform&secret=9e0891a7a8c8e885&overwrite=true",
+        imagesArr: [],
+        iframeSrc: "",
+        dialog: {
+          details: false
+        }
+      };
     },
-    //删除图片
-    delImage(i, key) {
-      if (this.type == "video") {
-        this.videoPicArr = this.videoPicArr.map(item => {
-          if (item.substring(0, item.length - 3) == this.imagesArr[i].substring(0, this.imagesArr[i].length - 3)) {
-            return undefined
-          } else {
-            return item
-          }
-        }).filter(p => p)
-      }
-      this.imagesArr.splice(i, 1);
-      this.$emit("change", this.imagesArr, this.defined, this.videoPicArr);
+    created() {
+      this.imageFalg();
     },
+    methods: {
+      //判断是否为空
+      imageFalg() {
+        let type = typeof this.keysArr;
+        if (type == "string") {
+          this.imagesArr = [this.keysArr];
+        } else {
+          this.imagesArr = tools.deepCopy(this.keysArr);
+        }
 
-    //上传
-    uploadAndSubmit(item, key) {
-      // var form = document.forms["demoForm"];
+        if (!this.keysArr) {
+          this.imagesArr = [];
+        }
+      },
+      //查看图片
+      lookImg() {
+        this.dialog.details = true
+        this.iframeSrc = process.env.BASE_URL + ":8890/photo-View.html"
+      },
+      //删除图片
+      delImage(i, key) {
+        if (this.type == "video") {
+          this.videoPicArr = this.videoPicArr.map(item => {
+            if (item.substring(0, item.length - 3) == this.imagesArr[i].substring(0, this.imagesArr[i].length - 3)) {
+              return undefined
+            } else {
+              return item
+            }
+          }).filter(p => p)
+        }
+        this.imagesArr.splice(i, 1);
+        this.$emit("change", this.imagesArr, this.defined, this.videoPicArr);
+      },
 
-      // if (form["file"].files.length > 0) {
-      // 寻找表单域中的 <input type="file" ... /> 标签
-      // var file = form["file"].files[0];
+      //上传
+      uploadAndSubmit(item, key) {
+        // var form = document.forms["demoForm"];
 
-      let file = item.file;
-      // try sending
-      let reader = new FileReader();
+        // if (form["file"].files.length > 0) {
+        // 寻找表单域中的 <input type="file" ... /> 标签
+        // var file = form["file"].files[0];
 
-      let vm = this;
+        let file = item.file;
+        // try sending
+        let reader = new FileReader();
 
-      let fileType = file.name.split(".");
-      let type = fileType[fileType.length - 1];
+        let vm = this;
 
-      let uploadKey = file.uid
-      if (!!key) {
-        uploadKey = key
-      }
+        let fileType = file.name.split(".");
+        let type = fileType[fileType.length - 1];
+        let CreateTime = tools.formatDate(new Date(file.lastModified))
 
-      reader.onloadstart = function () {
-        // 这个事件在读取开始时触发
-      };
-      reader.onprogress = function (p) {
-        // 这个事件在读取进行中定时触发
-      };
+        let uploadKey = file.uid
+        if (!!key) {
+          uploadKey = key
+        }
 
-      reader.onload = function () {
-        // 这个事件在读取成功结束后触发
-      };
-      reader.onloadend = function () {
-        // 这个事件在读取结束后,无论成功或者失败都会触发
-        if (reader.error) {
-        } else {
-          // document.getElementById("bytesRead").textContent = file.size;
-          // 构造 XMLHttpRequest 对象,发送文件 Binary 数据
-          var xhr = new XMLHttpRequest();
-          xhr.open(
-            /* method */
-            "POST",
-            /* target url */
-            vm.imageUploadUrl + "&key=" + uploadKey + "." + type
-            /*, async, default to true */
-          );
-          //xhr.overrideMimeType("application/octet-stream");
-          xhr.send(reader.result);
-          xhr.onreadystatechange = function () {
-            if (xhr.readyState == 4) {
-              if (xhr.status == 200) {
-                if (vm.type == 'image') {
-                  vm.imagesArr.push({
-                    name: uploadKey + '',
-                    key: uploadKey + "." + type,
-                    systemId: "dataPlatform",
-                    type: "image"
-                  });
-                }
-                if (type == 'mp4') {
-                  vm.imagesArr.push({
-                    name: uploadKey + '',
-                    key: uploadKey + "." + type,
-                    systemId: "dataPlatform",
-                    type: "video"
-                  });
-                  vm.creatImg(vm.imageGetUrl + "&key=" + uploadKey + "." + type, uploadKey)
-                }
-                console.log(vm.type, type)
-                if (vm.type == "video" && type == "png") {
-                  console.log("触发时评上传图片回调")
-                  vm.videoPicArr.push(uploadKey + "." + type)
+        reader.onloadstart = function () {
+          // 这个事件在读取开始时触发
+        };
+        reader.onprogress = function (p) {
+          // 这个事件在读取进行中定时触发
+        };
+
+        reader.onload = function () {
+          // 这个事件在读取成功结束后触发
+        };
+        reader.onloadend = function () {
+          // 这个事件在读取结束后,无论成功或者失败都会触发
+          if (reader.error) {
+          } else {
+            // document.getElementById("bytesRead").textContent = file.size;
+            // 构造 XMLHttpRequest 对象,发送文件 Binary 数据
+            var xhr = new XMLHttpRequest();
+            xhr.open(
+              /* method */
+              "POST",
+              /* target url */
+              vm.imageUploadUrl + "&key=" + uploadKey + "." + type
+              /*, async, default to true */
+            );
+            //xhr.overrideMimeType("application/octet-stream");
+            xhr.send(reader.result);
+            xhr.onreadystatechange = function () {
+              if (xhr.readyState == 4) {
+                if (xhr.status == 200) {
+                  if (vm.type == 'image') {
+                    vm.imagesArr.push({
+                      Name: uploadKey + '',
+                      Key: uploadKey + "." + type,
+                      SystemId: "dataPlatform",
+                      Type: "image",
+                      CreateTime
+                    });
+                  }
+                  if (type == 'mp4') {
+                    vm.imagesArr.push({
+                      Name: uploadKey + '',
+                      Key: uploadKey + "." + type,
+                      SystemId: "dataPlatform",
+                      Type: "video",
+                      CreateTime
+                    });
+                    vm.creatImg(vm.imageGetUrl + "&key=" + uploadKey + "." + type, uploadKey)
+                  }
+                  console.log(vm.type, type)
+                  if (vm.type == "video" && type == "png") {
+                    console.log("触发时评上传图片回调")
+                    vm.videoPicArr.push(uploadKey + "." + type)
+                  }
+                  vm.$emit("change", vm.imagesArr, vm.defined, vm.videoPicArr);
                 }
-                vm.$emit("change", vm.imagesArr, vm.defined, vm.videoPicArr);
               }
-            }
-          };
+            };
+          }
+        };
+        reader.readAsArrayBuffer(file);
+      },
+      dataURLtoBlob: function (dataURI, type) {
+        var binary = atob(dataURI.split(',')[1]);
+        var array = [];
+        for (var i = 0; i < binary.length; i++) {
+          array.push(binary.charCodeAt(i));
         }
-      };
-      reader.readAsArrayBuffer(file);
-    },
-    dataURLtoBlob: function (dataURI, type) {
-      var binary = atob(dataURI.split(',')[1]);
-      var array = [];
-      for (var i = 0; i < binary.length; i++) {
-        array.push(binary.charCodeAt(i));
-      }
-      return new Blob([new Uint8Array(array)], { type: type });
-    },
+        return new Blob([new Uint8Array(array)], {type: type});
+      },
 
-    creatImg(reader, key) {
-      var videoDom = document.getElementById('video');
-      videoDom.src = reader;
-      let vm = this
-      videoDom.onloadeddata = function () {
-        // 这里可以打印视频时长
-        // 这里取得视频封面
-        var canvas = document.createElement('canvas');
-        canvas.width = 300;
-        canvas.height = 300 * this.videoHeight / this.videoWidth;
-        canvas.getContext('2d').drawImage(this, 0, 0, canvas.width, canvas.height);
-        //将canvas的base64位图片转换成图片png的file
-        var blob = vm.dataURLtoBlob(canvas.toDataURL('image/png'), "image/png")
-        //将其转换成file对象
-        var file = new File([blob], "video_image.png", { type: "image/png", lastModified: Date.now() })//blob转file
-        vm.uploadAndSubmit({ file: file }, key)
+      creatImg(reader, key) {
+        var videoDom = document.getElementById('video');
+        videoDom.src = reader;
+        let vm = this
+        videoDom.onloadeddata = function () {
+          // 这里可以打印视频时长
+          // 这里取得视频封面
+          var canvas = document.createElement('canvas');
+          canvas.width = 300;
+          canvas.height = 300 * this.videoHeight / this.videoWidth;
+          canvas.getContext('2d').drawImage(this, 0, 0, canvas.width, canvas.height);
+          //将canvas的base64位图片转换成图片png的file
+          var blob = vm.dataURLtoBlob(canvas.toDataURL('image/png'), "image/png")
+          //将其转换成file对象
+          var file = new File([blob], "video_image.png", {type: "image/png", lastModified: Date.now()})//blob转file
+          vm.uploadAndSubmit({file: file}, key)
+        }
+      },
+    },
+    watch: {
+      keysArr: function (val) {
+        this.imageFalg();
       }
     },
-  },
-  watch: {
-    keysArr: function (val) {
-      this.imageFalg();
-    }
-  },
-  //自定义指令
-  directives: {
-    load: function (el) {
-      let imgDom = document.createElement("img");
-      imgDom.style.position = "absolute";
-      imgDom.style.top = "-999px";
-      imgDom.style.opacity = 0;
-      imgDom.src = el.src;
-      el.src = "";
-      imgDom.onload = () => {
-        let width = imgDom.width;
-        let height = imgDom.height;
-        if (width > height) {
-          el.style.height = "100%";
-          el.style.width = "auto";
-          el.style.position = "absolute";
-          el.style.left = "50%";
-          el.style.top = "0";
-          el.style.transform = "translateX(-50%)";
-          el.style.webkitTransform = "translateX(-50%) translateY(0)";
-          el.style.MozTransform = "translateX(-50%) translateY(0)";
-          el.style.msTransform = "translateX(-50%) translateY(0)";
-          el.style.OTransform = "translateX(-50%) translateY(0)";
-        } else if (width < height) {
+    //自定义指令
+    directives: {
+      load: function (el) {
+        let imgDom = document.createElement("img");
+        imgDom.style.position = "absolute";
+        imgDom.style.top = "-999px";
+        imgDom.style.opacity = 0;
+        imgDom.src = el.src;
+        el.src = "";
+        imgDom.onload = () => {
+          let width = imgDom.width;
+          let height = imgDom.height;
+          if (width > height) {
+            el.style.height = "100%";
+            el.style.width = "auto";
+            el.style.position = "absolute";
+            el.style.left = "50%";
+            el.style.top = "0";
+            el.style.transform = "translateX(-50%)";
+            el.style.webkitTransform = "translateX(-50%) translateY(0)";
+            el.style.MozTransform = "translateX(-50%) translateY(0)";
+            el.style.msTransform = "translateX(-50%) translateY(0)";
+            el.style.OTransform = "translateX(-50%) translateY(0)";
+          } else if (width < height) {
+            el.src = imgDom.src;
+            el.style.width = "100%";
+            el.style.height = "auto";
+            el.style.position = "absolute";
+            el.style.top = "50%";
+            el.style.left = "0";
+            el.style.transform = "translateY(-50%) translateX(0)";
+            el.style.webkitTransform = "translateY(-50%) translateX(0)";
+            el.style.MozTransform = "translateY(-50%) translateX(0)";
+            el.style.msTransform = "translateY(-50%) translateX(0)";
+            el.style.OTransform = "translateY(-50%) translateX(0)";
+          } else {
+            el.style.width = "100%";
+            el.style.height = "100%";
+            el.style.position = "absolute";
+            el.style.top = "0";
+            el.style.left = "0";
+            el.style.transform = "translateY(0) translateX(0)";
+            el.style.webkitTransform = "translateY(0) translateX(0)";
+            el.style.MozTransform = "translateY(0) translateX(0)";
+            el.style.msTransform = "translateY(0) translateX(0)";
+            el.style.OTransform = "translateY(0) translateX(0)";
+          }
           el.src = imgDom.src;
-          el.style.width = "100%";
-          el.style.height = "auto";
-          el.style.position = "absolute";
-          el.style.top = "50%";
-          el.style.left = "0";
-          el.style.transform = "translateY(-50%) translateX(0)";
-          el.style.webkitTransform = "translateY(-50%) translateX(0)";
-          el.style.MozTransform = "translateY(-50%) translateX(0)";
-          el.style.msTransform = "translateY(-50%) translateX(0)";
-          el.style.OTransform = "translateY(-50%) translateX(0)";
-        } else {
-          el.style.width = "100%";
-          el.style.height = "100%";
-          el.style.position = "absolute";
-          el.style.top = "0";
-          el.style.left = "0";
-          el.style.transform = "translateY(0) translateX(0)";
-          el.style.webkitTransform = "translateY(0) translateX(0)";
-          el.style.MozTransform = "translateY(0) translateX(0)";
-          el.style.msTransform = "translateY(0) translateX(0)";
-          el.style.OTransform = "translateY(0) translateX(0)";
-        }
-        el.src = imgDom.src;
-      };
+        };
+      }
     }
-  }
-};
+  };
 </script>
 <style lang="less">
-#sagaUploads {
-  overflow: hidden;
-  .avatar-uploader {
-    height: 180px;
-    width: 180px;
+  #sagaUploads {
     overflow: hidden;
-    .el-upload {
-      width: 180px;
+
+    .avatar-uploader {
       height: 180px;
-      .el-upload-dragger {
+      width: 180px;
+      overflow: hidden;
+
+      .el-upload {
         width: 180px;
         height: 180px;
-        .el-icon-plus {
-          display: block;
-          width: 20px;
-          height: 20px;
-          font-size: 20px;
-          margin: 80px;
+
+        .el-upload-dragger {
+          width: 180px;
+          height: 180px;
+
+          .el-icon-plus {
+            display: block;
+            width: 20px;
+            height: 20px;
+            font-size: 20px;
+            margin: 80px;
+          }
         }
       }
     }
-  }
-  .point-image {
-    width: 180px;
-    height: 180px;
-    float: left;
-    position: relative;
-    margin-right: 10px;
-    margin-bottom: 10px;
-    border: 1px solid #ccc;
-    overflow: hidden;
-    image {
-      z-index: 11;
-    }
-    i {
-      position: absolute;
-      bottom: 10px;
-      right: 10px;
-      background-color: #fff;
-      padding: 5px;
-      cursor: pointer;
-      z-index: 66;
+
+    .point-image {
+      width: 180px;
+      height: 180px;
+      float: left;
+      position: relative;
+      margin-right: 10px;
+      margin-bottom: 10px;
+      border: 1px solid #ccc;
+      overflow: hidden;
+
+      image {
+        z-index: 11;
+      }
+
+      i {
+        position: absolute;
+        bottom: 10px;
+        right: 10px;
+        background-color: #fff;
+        padding: 5px;
+        cursor: pointer;
+        z-index: 66;
+      }
     }
   }
-}
 </style>

+ 26 - 22
src/components/ledger/lib/uploadImgsName.vue

@@ -10,9 +10,9 @@
       <div v-if="type != 'video'" class="point-view" v-for="(item,index) in imagesArr">
         <div class="point-image">
           <i v-if="!readOnly" class="el-icon-delete" @click="delImage(index,item)"></i>
-          <img @click="lookImg" :src="imageGetUrl + '&key=' +item.key" alt v-load>
+          <img @click="lookImg" :src="imageGetUrl + '&key=' +item.Key" alt v-load>
         </div>
-        <form-input :label="''" @change="getName" :keys="index" :value="item.name" :width="10"></form-input>
+        <form-input :label="''" @change="getName" :keys="index" :value="item.Name" :width="10"></form-input>
       </div>
       <div v-if="type == 'video'" class="point-view" v-for="(item,index) in imagesArr">
         <div class="point-image">
@@ -20,13 +20,14 @@
           <video
             width="100%"
             height="100%;"
-            :src="imageGetUrl + '&key=' +item.key"
+            :src="imageGetUrl + '&key=' +item.Key"
             controls="controls"
           >您的浏览器不支持 video 标签。</video>
         </div>
-        <form-input :label="''" @change="getName" :keys="index" :value="item.name" :width="10"></form-input>
+        <form-input :label="''" @change="getName" :keys="index" :value="item.Name" :width="10"></form-input>
       </div>
-      <div v-if="!readOnly && imagesArr.length < max" style="float:left;">
+      <!--      v-if="!readOnly && imagesArr.length < max"-->
+      <div style="float:left;">
         <el-upload
           class="avatar-uploader"
           :http-request="uploadAndSubmit"
@@ -45,11 +46,11 @@
   </div>
 </template>
 <script>
-import tools from "@/utils/scan/tools";
-import formInput from "@/components/business_space/lib/formInput"
-import detailsDialog from "@/components/business_space/lib/detailsDia"
+  import tools from "@/utils/scan/tools";
+  import formInput from "@/components/business_space/lib/formInput"
+  import detailsDialog from "@/components/business_space/lib/detailsDia"
 
-export default {
+  export default {
   components: {
     formInput,
     detailsDialog
@@ -99,7 +100,6 @@ export default {
   },
   methods: {
     getName(name, index) {
-      console.log(this.imagesArr, "imagesArr")
       this.imagesArr[index].name = name
       this.$emit("change", this.imagesArr, this.defined, this.videoPicArr);
     },
@@ -154,6 +154,7 @@ export default {
 
       let fileType = file.name.split(".");
       let type = fileType[fileType.length - 1];
+      let CreateTime = tools.formatDate(new Date(file.lastModified))
 
       let uploadKey = file.uid
       if (!!key) {
@@ -192,29 +193,32 @@ export default {
                 if (vm.type == 'image') {
                   vm.imagesArr.push(
                     {
-                      name: uploadKey + '',
-                      key: uploadKey + "." + type,
-                      systemId: "dataPlatform",
-                      type: "image"
+                      Name: uploadKey + '',
+                      Key: uploadKey + "." + type,
+                      SystemId: "dataPlatform",
+                      Type: "image",
+                      CreateTime
                     }
                   );
                 }
                 if (type == 'mp4') {
                   vm.imagesArr.push({
-                    name: uploadKey + '',
-                    key: uploadKey + "." + type,
-                    systemId: "dataPlatform",
-                    type: "video"
+                      Name: uploadKey + '',
+                      Key: uploadKey + "." + type,
+                      SystemId: "dataPlatform",
+                      Type: "video",
+                      CreateTime
                   }
                   );
                   vm.creatImg(vm.imageGetUrl + "&key=" + uploadKey + "." + type, uploadKey)
                 }
                 if (vm.type == "video" && type == "png") {
                   vm.videoPicArr.push({
-                    name: uploadKey + '',
-                    key: uploadKey + "." + type,
-                    systemId: "dataPlatform",
-                    type: "image_video"
+                    Name: uploadKey + '',
+                    Key: uploadKey + "." + type,
+                    SystemId: "dataPlatform",
+                    Type: "image_video",
+                    CreateTime
                   })
                 }
                 vm.$emit("change", vm.imagesArr, vm.defined, vm.videoPicArr);

+ 426 - 415
src/utils/scan/tools.js

@@ -1,213 +1,277 @@
 import Handsontable from "handsontable-pro"
+
 const tools = {}
 
 let arrX = []
 let arrY = []
 tools.getPointDetails = (arr) => {
-        arr.map(item => {
-            if (item.PointList && item.PointList.length) {
-                item.PointList.map(em => {
-                    arrX.push(em.X)
-                    arrY.push(em.Y)
-                })
-            }
-        })
-    }
-    /**
-     * 
-     * @param {*} obj 将point标签的x,y进行比对
-     * @return object 返回数组,其中包括最大值最小值X,Y 
-     */
-tools.getPoint = function(obj) {
-    arrX = []
-    arrY = []
-    for (let i in obj) {
-        tools.getPointDetails(obj[i])
-    }
-    let maxX = Math.max.apply(null, arrX)
-    let minX = Math.min.apply(null, arrX)
-    let maxY = Math.max.apply(null, arrY)
-    let minY = Math.min.apply(null, arrY)
-    let data = {
-        maxX,
-        minX,
-        maxY,
-        minY
+  arr.map(item => {
+    if (item.PointList && item.PointList.length) {
+      item.PointList.map(em => {
+        arrX.push(em.X)
+        arrY.push(em.Y)
+      })
     }
-    return data
+  })
+}
+/**
+ *
+ * @param {*} obj 将point标签的x,y进行比对
+ * @return object 返回数组,其中包括最大值最小值X,Y
+ */
+tools.getPoint = function (obj) {
+  arrX = []
+  arrY = []
+  for (let i in obj) {
+    tools.getPointDetails(obj[i])
+  }
+  let maxX = Math.max.apply(null, arrX)
+  let minX = Math.min.apply(null, arrX)
+  let maxY = Math.max.apply(null, arrY)
+  let minY = Math.min.apply(null, arrY)
+  let data = {
+    maxX,
+    minX,
+    maxY,
+    minY
+  }
+  return data
 }
 
 /**
- * 
+ *
  * @param {*} array  比较数组1
  * @param {*} array2 比较数组2
- * 
+ *
  * 返回两个数组中不同的元素
  */
-tools.compareArr = function(array, array2) {
-    var arr3 = [];
-    for (key in array) {
-        var stra = array[key];
-        var count = 0;
-        for (var j = 0; j < array2.length; j++) {
-            var strb = array2[j];
-            if (stra == strb) {
-                count++;
-            }
-        }
-        if (count === 0) { //表示数组1的这个值没有重复的,放到arr3列表中  
-            arr3.push(stra);
-        }
+tools.compareArr = function (array, array2) {
+  var arr3 = [];
+  for (key in array) {
+    var stra = array[key];
+    var count = 0;
+    for (var j = 0; j < array2.length; j++) {
+      var strb = array2[j];
+      if (stra == strb) {
+        count++;
+      }
     }
-    return arr3;
+    if (count === 0) { //表示数组1的这个值没有重复的,放到arr3列表中
+      arr3.push(stra);
+    }
+  }
+  return arr3;
 }
 
 /**
- * 
+ *
  * @param {*} arr 需要改变的数组
  * @param {*} k   其中Y值需要变换的倍数
  * @param {*} name arr中的key值
- * 
+ *
  * 返回arr map 后arr[mapIndex]name * k 的数组
  */
-tools.changeMap = function(arr, k, name) {
-    let data = arr.map(items => {
-        if (items[name] && items[name].length) {
-            items[name].map(children => {
-                if (Array.isArray(children)) {
-                    return children.map(res => {
-                        res.Y = res.Y * k
-                        return res
-                    })
-                } else {
-                    children.Y = children.Y * k
-                    return children
-                }
-            })
+tools.changeMap = function (arr, k, name) {
+  let data = arr.map(items => {
+    if (items[name] && items[name].length) {
+      items[name].map(children => {
+        if (Array.isArray(children)) {
+          return children.map(res => {
+            res.Y = res.Y * k
+            return res
+          })
+        } else {
+          children.Y = children.Y * k
+          return children
         }
-    })
-    return data
+      })
+    }
+  })
+  return data
 }
 
-tools.getMouseCanvas = function(view, e) {
-    let bbox = view.canvasView.getBoundingClientRect();
-    let x = e.clientX - bbox.left,
-        y = e.clientY - bbox.top;
-    return view.mapToScene({
-        x: x,
-        y: y
-    });
+tools.getMouseCanvas = function (view, e) {
+  let bbox = view.canvasView.getBoundingClientRect();
+  let x = e.clientX - bbox.left,
+    y = e.clientY - bbox.top;
+  return view.mapToScene({
+    x: x,
+    y: y
+  });
 }
 
 /**
- * 
+ *
  * @param {*} view graphy class
  * @param {*} e    mouse元素e
  */
-tools.mouseInElement = function(view, e, type) {
-    let mouse = tools.getMouseCanvas(view, e),
-        falg = false,
-        items = view.scene.root.children,
-        i = 0,
-        t = type || 3;
-    for (; i < items.length; i++) {
-        if (items[i].type == t) {
-            if (items[i].contains(mouse)) {
-                falg = true
-                break
-            }
-        }
-    }
-    return {
-        falg,
-        item: items[i] || [],
-        index: i
+tools.mouseInElement = function (view, e, type) {
+  let mouse = tools.getMouseCanvas(view, e),
+    falg = false,
+    items = view.scene.root.children,
+    i = 0,
+    t = type || 3;
+  for (; i < items.length; i++) {
+    if (items[i].type == t) {
+      if (items[i].contains(mouse)) {
+        falg = true
+        break
+      }
     }
+  }
+  return {
+    falg,
+    item: items[i] || [],
+    index: i
+  }
 }
 
 /**
- * 
- * @param {graphy中的所有children} items 
- * @param {类型} type 
- * @param {list} codes 
- * @param {item中的code} code 
+ *
+ * @param {graphy中的所有children} items
+ * @param {类型} type
+ * @param {list} codes
+ * @param {item中的code} code
  */
-tools.clear = function(items, type, codes, code) {
-    let indexArr = [];
-    if (items && items.length) {
-        let i = 0;
-        for (i; i < items.length; i++) {
-            let j = 0;
-            for (j; j < codes.length; j++) {
-                if (items[i][type] = type && items[i][code] == codes[j][code]) {
-                    indexArr.push(i)
-                }
-            }
+tools.clear = function (items, type, codes, code) {
+  let indexArr = [];
+  if (items && items.length) {
+    let i = 0;
+    for (i; i < items.length; i++) {
+      let j = 0;
+      for (j; j < codes.length; j++) {
+        if (items[i][type] = type && items[i][code] == codes[j][code]) {
+          indexArr.push(i)
         }
+      }
     }
-    return indexArr
+  }
+  return indexArr
 }
 
-tools.getText = function(arr, name) {
-    let text = '';
-    if (arr && arr.length) {
-        arr.map(item => {
-            text += (!!text ? '、' : '') + item[name]
-        })
-    }
-    return text
+tools.getText = function (arr, name) {
+  let text = '';
+  if (arr && arr.length) {
+    arr.map(item => {
+      text += (!!text ? '、' : '') + item[name]
+    })
+  }
+  return text
 }
 
-tools.cutString = function(string, num, text) {
-    return string.substring(0, num) + '...' + text
+tools.cutString = function (string, num, text) {
+  return string.substring(0, num) + '...' + text
 }
 
-tools.deepCopy = function(obj) {
-    var out = [],
-        i = 0,
-        len = obj.length;
-    for (; i < len; i++) {
-        if (obj[i] instanceof Array) {
-            out[i] = tools.deepCopy(obj[i]);
-        } else out[i] = obj[i];
-    }
-    return out;
+tools.deepCopy = function (obj) {
+  var out = [],
+    i = 0,
+    len = obj.length;
+  for (; i < len; i++) {
+    if (obj[i] instanceof Array) {
+      out[i] = tools.deepCopy(obj[i]);
+    } else out[i] = obj[i];
+  }
+  return out;
 }
 
 tools.copyArr = (source) => {
-    if (!source || typeof source !== 'object') {
-        throw new Error('error arguments', 'shallowClone');
-    }
-    var targetObj = source.constructor === Array ? [] : {};
-    for (var keys in source) {
-        if (source.hasOwnProperty(keys)) {
-            if (source[keys] && typeof source[keys] === 'object') {
-                targetObj[keys] = source[keys].constructor === Array ? [] : {};
-                targetObj[keys] = tools.copyArr(source[keys]);
-            } else {
-                targetObj[keys] = source[keys];
-            }
-        }
+  if (!source || typeof source !== 'object') {
+    throw new Error('error arguments', 'shallowClone');
+  }
+  var targetObj = source.constructor === Array ? [] : {};
+  for (var keys in source) {
+    if (source.hasOwnProperty(keys)) {
+      if (source[keys] && typeof source[keys] === 'object') {
+        targetObj[keys] = source[keys].constructor === Array ? [] : {};
+        targetObj[keys] = tools.copyArr(source[keys]);
+      } else {
+        targetObj[keys] = source[keys];
+      }
     }
-    return targetObj;
+  }
+  return targetObj;
 }
 
-tools.deepCopyObj = function(v) {
-    var o = v.constructor === Array ? [] : {};
-    for (var key in v) {
-        o[key] = typeof v[key] === 'Object' ? tools.deepCopyObj(v[key]) : v[key];
-    }
+tools.deepCopyObj = function (v) {
+  var o = v.constructor === Array ? [] : {};
+  for (var key in v) {
+    o[key] = typeof v[key] === 'Object' ? tools.deepCopyObj(v[key]) : v[key];
+  }
 
-    return o;
+  return o;
 }
 
 tools.deepClone = (obj) => {
-    var proto = Object.getPrototypeOf(obj);
-    return Object.assign({}, Object.create(proto), obj);
+  var proto = Object.getPrototypeOf(obj);
+  return Object.assign({}, Object.create(proto), obj);
 }
 
 //hansontable插件的修改
-tools.customDropdownRenderer = function(
+tools.customDropdownRenderer = function (
+  instance,
+  td,
+  row,
+  col,
+  prop,
+  value,
+  cellProperties
+) {
+  var selectedId;
+  var optionsList = cellProperties.chosenOptions.data;
+  if (
+    typeof optionsList === "undefined" ||
+    typeof optionsList.length === "undefined" ||
+    !optionsList.length
+  ) {
+    Handsontable.renderers.TextRenderer(
+      instance,
+      td,
+      row,
+      col,
+      prop,
+      value,
+      cellProperties
+    );
+    return td;
+  }
+  var values = (value + "").split(",");
+  value = [];
+  for (var index = 0; index < optionsList.length; index++) {
+    if (optionsList[index].content && optionsList[index].content.length) {
+      for (let i = 0; i < optionsList[index].content.length; i++) {
+        if (
+          optionsList[index].content[i] &&
+          optionsList[index].content[i].length
+        ) {
+          for (let j = 0; j < optionsList[index].content[i].length; j++) {
+            if (
+              values.indexOf(
+                optionsList[index].content[i].content[j].Code + ""
+              ) > -1
+            ) {
+              selectedId = optionsList[index].content[i].content[j].Code;
+              value.push(optionsList[index].content[i].content[j].Name);
+            }
+          }
+        } else {
+          if (
+            values.indexOf(optionsList[index].content[i].Code + "") > -1
+          ) {
+            selectedId = optionsList[index].content[i].Code;
+            value.push(optionsList[index].content[i].Name);
+          }
+        }
+      }
+    } else {
+      if (values.indexOf(optionsList[index].Code + "") > -1) {
+        selectedId = optionsList[index].Code;
+        value.push(optionsList[index].Name);
+      }
+    }
+  }
+  value = value.join(", ");
+  Handsontable.renderers.TextRenderer(
     instance,
     td,
     row,
@@ -215,345 +279,292 @@ tools.customDropdownRenderer = function(
     prop,
     value,
     cellProperties
-) {
-    var selectedId;
-    var optionsList = cellProperties.chosenOptions.data;
-    if (
-        typeof optionsList === "undefined" ||
-        typeof optionsList.length === "undefined" ||
-        !optionsList.length
-    ) {
-        Handsontable.renderers.TextRenderer(
-            instance,
-            td,
-            row,
-            col,
-            prop,
-            value,
-            cellProperties
-        );
-        return td;
-    }
-    var values = (value + "").split(",");
-    value = [];
-    for (var index = 0; index < optionsList.length; index++) {
-        if (optionsList[index].content && optionsList[index].content.length) {
-            for (let i = 0; i < optionsList[index].content.length; i++) {
-                if (
-                    optionsList[index].content[i] &&
-                    optionsList[index].content[i].length
-                ) {
-                    for (let j = 0; j < optionsList[index].content[i].length; j++) {
-                        if (
-                            values.indexOf(
-                                optionsList[index].content[i].content[j].Code + ""
-                            ) > -1
-                        ) {
-                            selectedId = optionsList[index].content[i].content[j].Code;
-                            value.push(optionsList[index].content[i].content[j].Name);
-                        }
-                    }
-                } else {
-                    if (
-                        values.indexOf(optionsList[index].content[i].Code + "") > -1
-                    ) {
-                        selectedId = optionsList[index].content[i].Code;
-                        value.push(optionsList[index].content[i].Name);
-                    }
-                }
-            }
-        } else {
-            if (values.indexOf(optionsList[index].Code + "") > -1) {
-                selectedId = optionsList[index].Code;
-                value.push(optionsList[index].Name);
-            }
-        }
-    }
-    value = value.join(", ");
-    Handsontable.renderers.TextRenderer(
-        instance,
-        td,
-        row,
-        col,
-        prop,
-        value,
-        cellProperties
-    );
-    return td;
+  );
+  return td;
 }
 
 
 //hansontable插件查看详情
-tools.lookDetails = function(instance, td, row, col, prop, value, cellProperties) {
-    td.style.color = "#409EFF";
-    td.style.cursor = "pointer";
-    if (!!value) {
-        if (typeof(value) == 'object') {
-            td.innerHTML = "已有值,查看";
-        } else {
-            td.innerHTML = value
-        }
+tools.lookDetails = function (instance, td, row, col, prop, value, cellProperties) {
+  td.style.color = "#409EFF";
+  td.style.cursor = "pointer";
+  if (!!value) {
+    if (typeof (value) == 'object') {
+      td.innerHTML = "已有值,查看";
     } else {
-        td.innerHTML = "查看详情";
+      td.innerHTML = value
     }
-    return td;
+  } else {
+    td.innerHTML = "查看详情";
+  }
+  return td;
 }
 
 //是否关联
-tools.hasRelation = function(instance, td, row, col, prop, value, cellProperties) {
-    if (value) {
-        td.innerHTML = "已关联";
-    } else {
-        td.innerHTML = "未关联";
-    }
-    return td;
+tools.hasRelation = function (instance, td, row, col, prop, value, cellProperties) {
+  if (value) {
+    td.innerHTML = "已关联";
+  } else {
+    td.innerHTML = "未关联";
+  }
+  return td;
 }
 
 //关联的资产
-tools.LinkEquipLocalName = function(instance, td, row, col, prop, value, cellProperties) {
-    if (value) {
-        td.innerHTML = value;
-    } else {
-        td.innerHTML = instance.getDataAtRowProp(row,'LinkEquipName');
-    }
-    return td;
+tools.LinkEquipLocalName = function (instance, td, row, col, prop, value, cellProperties) {
+  if (value) {
+    td.innerHTML = value;
+  } else {
+    td.innerHTML = instance.getDataAtRowProp(row, 'LinkEquipName');
+  }
+  return td;
 }
 
-tools.num = function(instance, td, row, col, prop, value, cellProperties) {
-    td.style.color = "#409EFF";
-    td.style.cursor = "pointer";
-    td.innerHTML = value;
-    return td;
+tools.num = function (instance, td, row, col, prop, value, cellProperties) {
+  td.style.color = "#409EFF";
+  td.style.cursor = "pointer";
+  td.innerHTML = value;
+  return td;
 }
 
 tools.setItem = (key, value) => {
-    if (typeof value == 'string') {
-        localStorage.setItem(key, value);
-    } else {
-        localStorage.setItem(key, JSON.stringify(value));
-    }
+  if (typeof value == 'string') {
+    localStorage.setItem(key, value);
+  } else {
+    localStorage.setItem(key, JSON.stringify(value));
+  }
 }
 
 tools.getItem = (key) => {
-    const re = /^\[|\{|\}|\]$/g //判断字符中是否有[]{}
-    let getIt = localStorage.getItem(key)
-    if (re.test(getIt)) {
-        return JSON.parse(getIt)
-    } else {
-        return getIt
-    }
+  const re = /^\[|\{|\}|\]$/g //判断字符中是否有[]{}
+  let getIt = localStorage.getItem(key)
+  if (re.test(getIt)) {
+    return JSON.parse(getIt)
+  } else {
+    return getIt
+  }
 }
 
 tools.removeItem = (key) => {
-    localStorage.removeItem(key)
+  localStorage.removeItem(key)
 }
 
 //取两个数组的差值
 tools.differenceArr = (a, b) => {
-    return a.concat(b).filter(v => !a.includes(v) || !b.includes(v))
+  return a.concat(b).filter(v => !a.includes(v) || !b.includes(v))
 }
 
 //取两个数组的相同值
 tools.sameArr = (a, b) => {
-    return a.filter(v => b.includes(v))
+  return a.filter(v => b.includes(v))
 }
 
 tools.sortArr = (arr, key, sequence) => {
-    function compare(property) {
-        return function(a, b) {
-            var value1 = a[property];
-            var value2 = b[property];
-            if (sequence) {
-                return value1 - value2;
-            } else {
-                return value2 - value1
-            }
-        }
+  function compare(property) {
+    return function (a, b) {
+      var value1 = a[property];
+      var value2 = b[property];
+      if (sequence) {
+        return value1 - value2;
+      } else {
+        return value2 - value1
+      }
     }
+  }
 
-    return arr.sort(compare(key))
+  return arr.sort(compare(key))
 }
 
 tools.pagination = (pageNo, pageSize, array) => {
-    let offset = (pageNo - 1) * pageSize;
-    return offset + pageSize >= array.length ?
-        array.slice(offset, array.length) :
-        array.slice(offset, offset + pageSize);
+  let offset = (pageNo - 1) * pageSize;
+  return offset + pageSize >= array.length ?
+    array.slice(offset, array.length) :
+    array.slice(offset, offset + pageSize);
 }
 
 tools.getSameItems = (arr1, key1, arr2, key2) => {
-    let data = []
-    arr1.map(item => {
-        arr2.map(child => {
-            if (item[key1] == child[key2]) {
-                data.push(item)
-            }
-        })
+  let data = []
+  arr1.map(item => {
+    arr2.map(child => {
+      if (item[key1] == child[key2]) {
+        data.push(item)
+      }
     })
-    return data
+  })
+  return data
 }
 
 tools.isIn = (x, y, json) => {
-    let nCross = 0,
-        point = typeof(x) == 'object' ? [x.x, x.y] : [x, y],
-        APoints = json,
-        length = APoints.length,
-        p1, p2, i, xinters;
-    p1 = APoints[0];
-    for (i = 1; i <= length; i++) {
-        p2 = APoints[i % length];
-        if (
-            point[0] > Math.min(p1[0], p2[0]) &&
-            point[0] <= Math.max(p1[0], p2[0])
-        ) {
-            if (point[1] <= Math.max(p1[1], p2[1])) {
-                if (p1[0] != p2[0]) {
-                    //计算位置信息
-                    xinters = (point[0] - p1[0]) * (p2[1] - p1[1]) / (p2[0] - p1[0]) + p1[1];
-                    if (p1[1] == p2[1] || point[1] <= xinters) {
-                        nCross++
-                    }
-                }
-            }
+  let nCross = 0,
+    point = typeof (x) == 'object' ? [x.x, x.y] : [x, y],
+    APoints = json,
+    length = APoints.length,
+    p1, p2, i, xinters;
+  p1 = APoints[0];
+  for (i = 1; i <= length; i++) {
+    p2 = APoints[i % length];
+    if (
+      point[0] > Math.min(p1[0], p2[0]) &&
+      point[0] <= Math.max(p1[0], p2[0])
+    ) {
+      if (point[1] <= Math.max(p1[1], p2[1])) {
+        if (p1[0] != p2[0]) {
+          //计算位置信息
+          xinters = (point[0] - p1[0]) * (p2[1] - p1[1]) / (p2[0] - p1[0]) + p1[1];
+          if (p1[1] == p2[1] || point[1] <= xinters) {
+            nCross++
+          }
         }
-        p1 = p2;
-    }
-    if (nCross % 2 == 0) {
-        return false
-    } else {
-        return true
+      }
     }
+    p1 = p2;
+  }
+  if (nCross % 2 == 0) {
+    return false
+  } else {
+    return true
+  }
 
 }
 
 tools.arrayUnique = (arr, name) => {
-    var hash = {};
-    return arr.reduce(function(item, next) {
-        hash[next[name]] ? '' : hash[next[name]] = true && item.push(next);
-        return item;
-    }, []);
-}
-
-tools.dateAddYear = function(date, yearCount) {
-    var tempDate = dateToDate(date);
-    var count = parseInt(yearCount);
-    var oldYear = tempDate.getFullYear();
-    var oldMonth = tempDate.getMonth();
-    var oldDate = tempDate.getDate();
-    var newYear = oldYear + count;
-    var newDate = new Date(newYear, oldMonth, oldDate);
-    //防止月份数不一致,进行微调
-    while (newDate.getMonth() != oldMonth) {
-        oldDate--;
-        newDate = new Date(newYear, oldMonth, oldDate);
-    }
-    var month = newDate.getMonth() + 1;
-    var day = newDate.getDate();
-    month = (month.toString().length == 1) ? ("0" + month) : month;
-    day = (day.toString().length == 1) ? ("0" + day) : day;
-
-    var result = newDate.getFullYear() + '-' + month + '-' + day; //当前日期
-
-    return result;
-}
-
-tools.formatDataSource = function(data) {
-    let options
+  var hash = {};
+  return arr.reduce(function (item, next) {
+    hash[next[name]] ? '' : hash[next[name]] = true && item.push(next);
+    return item;
+  }, []);
+}
+
+tools.dateAddYear = function (date, yearCount) {
+  var tempDate = dateToDate(date);
+  var count = parseInt(yearCount);
+  var oldYear = tempDate.getFullYear();
+  var oldMonth = tempDate.getMonth();
+  var oldDate = tempDate.getDate();
+  var newYear = oldYear + count;
+  var newDate = new Date(newYear, oldMonth, oldDate);
+  //防止月份数不一致,进行微调
+  while (newDate.getMonth() != oldMonth) {
+    oldDate--;
+    newDate = new Date(newYear, oldMonth, oldDate);
+  }
+  var month = newDate.getMonth() + 1;
+  var day = newDate.getDate();
+  month = (month.toString().length == 1) ? ("0" + month) : month;
+  day = (day.toString().length == 1) ? ("0" + day) : day;
+
+  var result = newDate.getFullYear() + '-' + month + '-' + day; //当前日期
+
+  return result;
+}
+tools.formatDate = (now) => {
+  let year = now.getFullYear();
+  let month = now.getMonth() + 1;
+  let date = now.getDate();
+  let hour = now.getHours();
+  let minute = now.getMinutes();
+  let second = now.getSeconds();
+  return year + "-" + month + "-" + (date > 10 ? date : '0' + date) + " " + hour + ":" + (minute > 10 ? minute : '0' + minute) + ":" + (second > 10 ? second : '0' + second);
+};
+tools.formatDataSource = function (data) {
+  let options
+  let arr = []
+
+  function recursion(data) {
     let arr = []
-    function recursion (data) {
-        let arr = []
-        data.map((item) =>{
-            if (item.Code && item.Name)
-            arr.push({ Code: item.Code, Name: item.Name })
-            if (item.Content && item.Content.length)
-            arr = arr.concat(recursion(item.Content))
-        })
-        return arr
-    }
-    try{
-        options = JSON.parse(data)
-        if(options) {
-            return recursion(options)
-        } else {
-            return arr
-        }
-    } catch (err) {
-        return arr
+    data.map((item) => {
+      if (item.Code && item.Name)
+        arr.push({Code: item.Code, Name: item.Name})
+      if (item.Content && item.Content.length)
+        arr = arr.concat(recursion(item.Content))
+    })
+    return arr
+  }
+
+  try {
+    options = JSON.parse(data)
+    if (options) {
+      return recursion(options)
+    } else {
+      return arr
     }
+  } catch (err) {
+    return arr
+  }
 }
 
 tools.isObjectValueEqual = function (a, b) {//判断两个对象的可枚举属性值是否相等(认为null,"",undefinde相等)
-    //取对象a和b的属性名
-    var aProps = Object.keys(a)
-    var bProps = Object.keys(b)
-    //判断属性名的length是否一致
-    if (aProps.length != bProps.length) {
+  //取对象a和b的属性名
+  var aProps = Object.keys(a)
+  var bProps = Object.keys(b)
+  //判断属性名的length是否一致
+  if (aProps.length != bProps.length) {
+    return false
+  }
+
+  //循环取出属性名,再判断属性值是否一致
+  for (var i = 0; i < aProps.length; i++) {
+    var propName = aProps[i]
+    if (!(a[propName] instanceof Object || b[propName] instanceof Object)) {
+      if (!(a[propName] == b[propName] || (!a[propName] && !b[propName]))) {
         return false
+      }
+    } else {
+      if (!tools.isObjectValueEqual(a[propName], b[propName])) {
+        return false
+      }
     }
-
-    //循环取出属性名,再判断属性值是否一致
-    for (var i = 0; i < aProps.length; i++) {
-        var propName = aProps[i]
-        if(!(a[propName] instanceof Object || b[propName] instanceof Object)) {
-            if (!(a[propName] == b[propName] || (!a[propName] && !b[propName]))) {
-                return false
-            }
-        } else {
-            if(!tools.isObjectValueEqual(a[propName],b[propName])) {
-                return false
-            }
-        }
-    }
-    return true
+  }
+  return true
 
 }
 
 tools.dataForKey = function (data, key) {
-    let arr = key.split(".")
-    if (arr && arr[0]) {
-      for (let i = 0; i < arr.length; i++) {
-        if (arr[i] && data[arr[i]]) {
-            data = data[arr[i]]
-        } else {
-            return ''
-        }
+  let arr = key.split(".")
+  if (arr && arr[0]) {
+    for (let i = 0; i < arr.length; i++) {
+      if (arr[i] && data[arr[i]]) {
+        data = data[arr[i]]
+      } else {
+        return ''
       }
-      return data
     }
+    return data
+  }
 }
 
 tools.setDataForKey = function (data, key, value) {
-    let arr = key.split(".")
-    if (arr && arr[0]) {
-      for (let i = 0; i < arr.length; i++) {
-        if (!(arr[i] && data[arr[i]])) {
-            data[arr[i]] = {}
+  let arr = key.split(".")
+  if (arr && arr[0]) {
+    for (let i = 0; i < arr.length; i++) {
+      if (!(arr[i] && data[arr[i]])) {
+        data[arr[i]] = {}
+      }
+      if (value !== undefined) {
+        if (i == arr.length - 1) {
+          data[arr[i]] = value
         }
-        if (value !== undefined) {
-            if (i == arr.length - 1) {
-                data[arr[i]] = value
-            }
-        } else {
-            if (i == arr.length - 1) {
-                data[arr[i]] = ''
-            }
+      } else {
+        if (i == arr.length - 1) {
+          data[arr[i]] = ''
         }
-        data = data[arr[i]]
       }
+      data = data[arr[i]]
     }
+  }
 }
 
 function dateToDate(date) {
-    var sDate = new Date();
-    if (typeof date == 'object' && typeof new Date().getMonth == "function") {
-        sDate = date;
-    } else if (typeof date == "string") {
-        var arr = date.split('-');
-        if (arr.length == 3) {
-            sDate = new Date(arr[0] + '-' + arr[1] + '-' + arr[2]);
-        }
+  var sDate = new Date();
+  if (typeof date == 'object' && typeof new Date().getMonth == "function") {
+    sDate = date;
+  } else if (typeof date == "string") {
+    var arr = date.split('-');
+    if (arr.length == 3) {
+      sDate = new Date(arr[0] + '-' + arr[1] + '-' + arr[2]);
     }
-    return sDate;
+  }
+  return sDate;
 }
 
 export default tools