ソースを参照

bug
Signed-off-by: lijunqing <lijunqing@dashoo.cn>

lijunqing 6 年 前
コミット
f24a1588c3

+ 29 - 0
src/dashoo.cn/backend/api/business/limscheckequipmentlist/limscheckequipmentlist.go

@@ -33,3 +33,32 @@ type LimsCheckEquipmentList struct {
 	ModifiedUserId  int       `xorm:"INT(10)"`
 	ModifiedBy      string    `xorm:"VARCHAR(50)"`
 }
+type LimsCheckEquipmentListUpload struct{
+	Uploadeds []ContractAttachmentarrt // 上传附件
+}
+
+// 附件model
+type ContractAttachmentarrt struct {
+	Host     string
+	FileId   string
+	FileName string
+	FileSize int32
+	FileURL  string
+}
+
+type Statutefile struct {
+	Id             int       `xorm:"not null pk autoincr INT(11)"`
+	EId            int       `xorm:"comment('关联s5OVELimsCheckEquipmentListId') INT(11)"`
+	FileUrl        string    `xorm:"not null comment('FileUrl') VARCHAR(100)"`
+	FileName       string    `xorm:"not null comment('文件名称') VARCHAR(100)"`
+	Host           string    `xorm:"not null comment('文件路径') VARCHAR(254)"`
+	FileId         string    `xorm:"not null comment('文件Id') VARCHAR(100)"`
+	FileSize       int       `xorm:"comment('文件大小') INT(11)"`
+	Remark         string    `xorm:"comment('备注') VARCHAR(1000)"`
+	CreateOn       time.Time `xorm:"DATETIME"`
+	CreateUserId   int       `xorm:"INT(10)"`
+	CreateBy       string    `xorm:"VARCHAR(50)"`
+	ModifiedOn     time.Time `xorm:"DATETIME"`
+	ModifiedUserId int       `xorm:"INT(10)"`
+	ModifiedBy     string    `xorm:"VARCHAR(50)"`
+}

+ 42 - 1
src/dashoo.cn/backend/api/controllers/lims/limscheckequipmentlist.go

@@ -203,10 +203,16 @@ func (this *LimsCheckEquipmentListController) GetEntity() {
 	Id := this.Ctx.Input.Param(":id")
 
 	var model limscheckequipmentlist.LimsCheckEquipmentList
+	var model1 []limscheckequipmentlist.Statutefile
 	svc := limscheckequipmentlist.GetLimsCheckEquipmentListService(utils.DBE)
 	svc.GetEntityByIdBytbl(this.User.AccCode+LimsCheckEquipmentListName, Id, &model)
+	svc.GetEntities(&model1," EId='"+Id+"'")
 
-	this.Data["json"] = &model
+	gatherData := make(map[string]interface{})
+	//登陆用户信息
+	gatherData["Items"] = model
+	gatherData["FileItems"] = model1
+	this.Data["json"] = &gatherData
 	this.ServeJSON()
 }
 
@@ -217,10 +223,12 @@ func (this *LimsCheckEquipmentListController) GetEntity() {
 // @router /add [post]
 func (this *LimsCheckEquipmentListController) AddEntity() {
 	var model limscheckequipmentlist.LimsCheckEquipmentList
+	var model1 limscheckequipmentlist.LimsCheckEquipmentListUpload
 	var jsonBlob = this.Ctx.Input.RequestBody
 	svc := limscheckequipmentlist.GetLimsCheckEquipmentListService(utils.DBE)
 
 	json.Unmarshal(jsonBlob, &model)
+	json.Unmarshal(jsonBlob, &model1)
 	model.CreateOn = time.Now()
 	model.CreateBy = this.User.Realname
 	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
@@ -242,6 +250,21 @@ func (this *LimsCheckEquipmentListController) AddEntity() {
 	}
 	_, err := svc.InsertEntityBytbl(this.User.AccCode+LimsCheckEquipmentListName, &model)
 
+
+	for _,item := range model1.Uploadeds {
+		var model2 limscheckequipmentlist.Statutefile
+		model2.EId=model.Id
+		model2.FileName = item.FileName
+		model2.FileSize = int(item.FileSize)
+		model2.Host = item.Host
+		model2.FileId = item.FileId
+		model2.FileUrl = item.FileURL
+		model2.Remark = ""
+		model2.CreateOn = time.Now()
+		model2.CreateBy = this.User.Realname
+		model2.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+		_, err = svc.InsertEntityBytbl("Statutefile", &model2)
+	}
 	var errinfo ErrorDataInfo
 	if err == nil {
 		//新增
@@ -275,10 +298,12 @@ func (this *LimsCheckEquipmentListController) UpdateEntity() {
 	}
 
 	var model limscheckequipmentlist.LimsCheckEquipmentList
+	var model1 limscheckequipmentlist.LimsCheckEquipmentListUpload
 	svc := limscheckequipmentlist.GetLimsCheckEquipmentListService(utils.DBE)
 
 	var jsonBlob = this.Ctx.Input.RequestBody
 	json.Unmarshal(jsonBlob, &model)
+	json.Unmarshal(jsonBlob, &model1)
 	model.ModifiedOn = time.Now()
 	model.ModifiedBy = this.User.Realname
 	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
@@ -345,6 +370,22 @@ func (this *LimsCheckEquipmentListController) UpdateEntity() {
 		"ModifiedBy",
 	}
 	err := svc.UpdateEntityBytbl(this.User.AccCode+LimsCheckEquipmentListName, id, &model, cols)
+
+	for _,item := range model1.Uploadeds {
+		var model2 limscheckequipmentlist.Statutefile
+		tempId,_:=strconv.Atoi(id)
+		model2.EId=tempId
+		model2.FileName = item.FileName
+		model2.FileSize = int(item.FileSize)
+		model2.Host = item.Host
+		model2.FileId = item.FileId
+		model2.FileUrl = item.FileURL
+		model2.Remark = ""
+		model2.CreateOn = time.Now()
+		model2.CreateBy = this.User.Realname
+		model2.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+		_, err = svc.InsertEntityBytbl("Statutefile", &model2)
+	}
 	if err == nil {
 		errinfo.Message = "修改成功!"
 		errinfo.Code = 0

+ 870 - 595
src/dashoo.cn/frontend_web/src/pages/lims/checkequipmentlist/index.vue

@@ -6,8 +6,15 @@
     </el-breadcrumb>-->
     <el-row :gutter="5">
       <el-col :span="6">
-        <el-tree style="height: calc(100vh - 75px); overflow: auto;" draggable highlight-current :expand-on-click-node="true" node-key="id" :data="customerTreeList" :props="orgtreeprops"
-                 @node-click="orgtreeNodeClick" ref="orgmanagetree">
+        <el-tree style="height: calc(100vh - 90px); overflow: auto;"
+                 draggable
+                 highlight-current
+                 :expand-on-click-node="true"
+                 node-key="id"
+                 :data="customerTreeList"
+                 :props="orgtreeprops"
+                 @node-click="orgtreeNodeClick"
+                 ref="orgmanagetree">
         </el-tree>
       </el-col>
       <el-col :span="18">
@@ -17,26 +24,47 @@
               <i class="icon icon-table2"></i>
             </span>
 
-            <el-form ref="form" :inline="true" style="float: right; margin-top: -10px">
+            <el-form ref="form"
+                     :inline="true"
+                     style="float: right; margin-top: -10px">
               <el-form-item label="状态">
-                 <el-select v-model="statusValue" clearable  @change="ProjectTypeChangeHandler" @clear="ProjectTypeClearHandler" placeholder="请选择" size="mini">
-                  <el-option
-                    v-for="item in statusOptions"
-                    :key="item.value"
-                    :label="item.label"
-                    :value="item.value">
+                <el-select v-model="statusValue"
+                           clearable
+                           @change="ProjectTypeChangeHandler"
+                           @clear="ProjectTypeClearHandler"
+                           placeholder="请选择"
+                           size="mini">
+                  <el-option v-for="item in statusOptions"
+                             :key="item.value"
+                             :label="item.label"
+                             :value="item.value">
                   </el-option>
                 </el-select>
               </el-form-item>
 
               <el-form-item label="设备分类">
-                <el-select ref="refQueryProjectType" style="margin-right:10px; margin-top: -4px;" size="mini" v-model="QueryProjectTypeId" clearable filterable placeholder="按设备分类查询" @change="ProjectTypeChangeHandler" @clear="ProjectTypeClearHandler">
-                  <el-option v-for="item in projectTypeList" :key="item.id" :label="item.FullName" :value="item.Id"></el-option>
+                <el-select ref="refQueryProjectType"
+                           style="margin-right:10px; margin-top: -4px;"
+                           size="mini"
+                           v-model="QueryProjectTypeId"
+                           clearable
+                           filterable
+                           placeholder="按设备分类查询"
+                           @change="ProjectTypeChangeHandler"
+                           @clear="ProjectTypeClearHandler">
+                  <el-option v-for="item in projectTypeList"
+                             :key="item.id"
+                             :label="item.FullName"
+                             :value="item.Id"></el-option>
                 </el-select>
               </el-form-item>
 
               <el-form-item>
-                <el-dropdown split-button type="primary" size="mini" @click="handleSearch" @command="searchCommand">
+                <el-dropdown split-button
+                             type="primary"
+                             size="mini"
+                             @click="handleSearch"
+                             @command="searchCommand">
                   查询
                   <el-dropdown-menu slot="dropdown">
                     <el-dropdown-item command="search">高级查询</el-dropdown-item>
@@ -45,40 +73,89 @@
                 </el-dropdown>
               </el-form-item>
               <el-form-item>
-                <el-button type="primary" size="mini" style="" @click="NewEntity">添加</el-button>
-                <el-button type="primary" size="mini" @click="exportExcel">导出</el-button>
+                <el-button type="primary"
+                           size="mini"
+                           style=""
+                           @click="NewEntity">添加</el-button>
+                <el-button type="primary"
+                           size="mini"
+                           @click="exportExcel">导出</el-button>
               </el-form-item>
             </el-form>
           </div>
-          <el-alert title="提示: 已过期为【红色】, 一个月内到期为【黄色】,正常为【绿色】" type="warning" :closable="false">
+          <el-alert title="提示: 已过期为【红色】, 一个月内到期为【黄色】,正常为【绿色】"
+                    type="warning"
+                    :closable="false">
           </el-alert>
-          <el-table :height="437" :data="entityList" border style="width: 100%;" @sort-change="orderby" :cell-class-name="tableRowClassName" size="mini">
-            <el-table-column label="操作" width="160px" align="center" fixed>
+          <el-table height="calc(100vh - 315px)"
+                    :data="entityList"
+                    border
+                    style="width: 100%;"
+                    @sort-change="orderby"
+                    :cell-class-name="tableRowClassName"
+                    size="mini">
+            <el-table-column label="操作"
+                             width="160px"
+                             align="center"
+                             fixed>
               <template slot-scope="scope">
-                <el-button type="primary" title="编辑" size="small" plain @click="ShowEntityDialog(scope.row.Id)">编辑</el-button>
-                <el-button type="plain" plain title="删除" size="small" style="margin-left:10px;" @click="deleteConfirm(scope.row)">删除</el-button>
+                <el-button type="primary"
+                           title="编辑"
+                           size="small"
+                           plain
+                           @click="ShowEntityDialog(scope.row.Id)">编辑</el-button>
+                <el-button type="plain"
+                           plain
+                           title="删除"
+                           size="small"
+                           style="margin-left:10px;"
+                           @click="deleteConfirm(scope.row)">删除</el-button>
               </template>
             </el-table-column>
 
-             <el-table-column label="状态" width="80px" align="center" >
+            <el-table-column label="状态"
+                             width="80px"
+                             align="center">
               <i class="el-icon-s-opportunity"></i>
             </el-table-column>
 
-            <el-table-column v-for="column in tableColumns" :key="column.Id" :prop="column.prop" sortable min-width="100" :label="column.label" align="center" show-overflow-tooltip></el-table-column>
+            <el-table-column v-for="column in tableColumns"
+                             :key="column.Id"
+                             :prop="column.prop"
+                             sortable
+                             min-width="100"
+                             :label="column.label"
+                             align="center"
+                             show-overflow-tooltip></el-table-column>
 
-            <el-table-column prop="LastCheckDate" sortable min-width="150" label="上次检测日期" align="center" show-overflow-tooltip>
+            <el-table-column prop="LastCheckDate"
+                             sortable
+                             min-width="150"
+                             label="上次检测日期"
+                             align="center"
+                             show-overflow-tooltip>
               <template slot-scope="scope">
                 {{ jstimehandle(scope.row.LastCheckDate+'') }}
               </template>
             </el-table-column>
 
-            <el-table-column prop="Cycle" sortable min-width="100" label="检测周期" align="center" show-overflow-tooltip>
+            <el-table-column prop="Cycle"
+                             sortable
+                             min-width="100"
+                             label="检测周期"
+                             align="center"
+                             show-overflow-tooltip>
               <template slot-scope="scope">
                 {{ scope.row.Cycle + ' ' + scope.row.CycleUnit }}
               </template>
             </el-table-column>
 
-              <el-table-column prop="NextCheckDate" sortable min-width="150" label="下次检测日期" align="center" show-overflow-tooltip>
+            <el-table-column prop="NextCheckDate"
+                             sortable
+                             min-width="150"
+                             label="下次检测日期"
+                             align="center"
+                             show-overflow-tooltip>
               <template slot-scope="scope">
                 {{ jstimehandle(scope.row.NextCheckDate+'') }}
               </template>
@@ -86,16 +163,24 @@
 
           </el-table>
           <div class="bottom clearfix">
-            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
-                          :page-sizes="[10, 15, 20, 25]" :page-size="size" layout="total, sizes, prev, pager, next, jumper" :total="currentItemCount">
+            <el-pagination @size-change="handleSizeChange"
+                           @current-change="handleCurrentChange"
+                           :current-page="currentPage"
+                           :page-sizes="[10, 15, 20, 25]"
+                           :page-size="size"
+                           layout="total, sizes, prev, pager, next, jumper"
+                           :total="currentItemCount">
             </el-pagination>
           </div>
         </el-card>
       </el-col>
     </el-row>
 
-    <el-dialog title="高级查询" :visible.sync="dialogVisible" width="720px">
-      <el-form ref="advancedsearchForm" label-width="110px">
+    <el-dialog title="高级查询"
+               :visible.sync="dialogVisible"
+               width="720px">
+      <el-form ref="advancedsearchForm"
+               label-width="110px">
         <el-row>
 
           <!-- <el-col :span="12">
@@ -119,38 +204,56 @@
 
           <el-col :span="12">
             <el-form-item label="检测地点">
-              <el-input size="mini" v-model="searchForm.PositionCheck" style="width:100%" placeholder="请输入"></el-input>
+              <el-input size="mini"
+                        v-model="searchForm.PositionCheck"
+                        style="width:100%"
+                        placeholder="请输入"></el-input>
             </el-form-item>
           </el-col>
 
           <el-col :span="12">
             <el-form-item label="安装位置">
-              <el-input size="mini" v-model="searchForm.Position" style="width:100%" placeholder="请输入"></el-input>
+              <el-input size="mini"
+                        v-model="searchForm.Position"
+                        style="width:100%"
+                        placeholder="请输入"></el-input>
             </el-form-item>
           </el-col>
 
           <el-col :span="12">
             <el-form-item label="规格型号">
-              <el-input size="mini" v-model="searchForm.Spec" style="width:100%" placeholder="请输入"></el-input>
+              <el-input size="mini"
+                        v-model="searchForm.Spec"
+                        style="width:100%"
+                        placeholder="请输入"></el-input>
             </el-form-item>
           </el-col>
 
           <el-col :span="12">
             <el-form-item label="制造厂家">
-              <el-input size="mini" v-model="searchForm.Manufacturer" style="width:100%" placeholder="请输入"></el-input>
+              <el-input size="mini"
+                        v-model="searchForm.Manufacturer"
+                        style="width:100%"
+                        placeholder="请输入"></el-input>
             </el-form-item>
           </el-col>
 
         </el-row>
       </el-form>
-      <span slot="footer" class="dialog-footer">
-        <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
-        <el-button size="mini" type="primary" @click="handleSearch">查 询</el-button>
+      <span slot="footer"
+            class="dialog-footer">
+        <el-button size="mini"
+                   @click="dialogVisible = false">取 消</el-button>
+        <el-button size="mini"
+                   type="primary"
+                   @click="handleSearch">查 询</el-button>
       </span>
     </el-dialog>
 
-    <el-dialog :title="addoredittitle" :visible.sync="dialogFormVisible">
-      <el-form :model="formData" ref="EntityForm">
+    <el-dialog :title="addoredittitle"
+               :visible.sync="dialogFormVisible">
+      <el-form :model="formData"
+               ref="EntityForm">
         <!-- <el-form-item label="序号" :label-width="formLabelWidth">
           <el-input-number v-model="formData.OrderNo" :min="1" style="width:100%" placeholder="请输入"></el-input-number>
         </el-form-item>
@@ -160,646 +263,818 @@
         <el-form-item label="设备名称" :label-width="formLabelWidth">
           <el-input v-model="formData.DeviceName" autocomplete="off"></el-input>
         </el-form-item> -->
-          <el-form-item label="编号" :label-width="formLabelWidth">
-          <el-input v-model="formData.CustNo" style="width:100%" placeholder="请输入"></el-input>
+        <el-form-item label="编号"
+                      :label-width="formLabelWidth">
+          <el-input v-model="formData.CustNo"
+                    style="width:100%"
+                    placeholder="请输入"></el-input>
         </el-form-item>
-        <el-form-item label="设备类型" :label-width="formLabelWidth" prop="TemplateTypeId" required>
-          <el-select ref="refProjectTypeId" v-model="formData.TemplateTypeId" style="width:100%" filterable placeholder="请选择" @change="changeDetectionCycle">
-            <el-option v-for="item in projectTypeList" :key="item.id" :label="item.FullName" :value="item.Id"></el-option>
+        <el-form-item label="设备类型"
+                      :label-width="formLabelWidth"
+                      prop="TemplateTypeId"
+                      required>
+          <el-select ref="refProjectTypeId"
+                     v-model="formData.TemplateTypeId"
+                     style="width:100%"
+                     filterable
+                     placeholder="请选择"
+                     @change="changeDetectionCycle">
+            <el-option v-for="item in projectTypeList"
+                       :key="item.id"
+                       :label="item.FullName"
+                       :value="item.Id"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="安装地点" :label-width="formLabelWidth" required>
-          <el-cascader
-            filterable
-            ref="cascaderPosition"
-            v-model="PositionList" placeholder="请选择安装地点"
-            :options="customerTreeList"
-            :props="orgtreeprops"
-            style="width: 100%;"
-            @change="handlePositionChange"></el-cascader>
+        <el-form-item label="安装地点"
+                      :label-width="formLabelWidth"
+                      required>
+          <el-cascader filterable
+                       ref="cascaderPosition"
+                       v-model="PositionList"
+                       placeholder="请选择安装地点"
+                       :options="customerTreeList"
+                       :props="orgtreeprops"
+                       style="width: 100%;"
+                       @change="handlePositionChange"></el-cascader>
         </el-form-item>
-        <el-form-item label="生产厂家" :label-width="formLabelWidth">
-          <el-input v-model="formData.Manufacturer" autocomplete="off"></el-input>
+        <el-form-item label="生产厂家"
+                      :label-width="formLabelWidth">
+          <el-input v-model="formData.Manufacturer"
+                    autocomplete="off"></el-input>
         </el-form-item>
-        <el-form-item label="设备型号" :label-width="formLabelWidth">
-          <el-input v-model="formData.Spec" autocomplete="off"></el-input>
+        <el-form-item label="设备型号"
+                      :label-width="formLabelWidth">
+          <el-input v-model="formData.Spec"
+                    autocomplete="off"></el-input>
         </el-form-item>
-        <el-form-item label="上次检测日期" :label-width="formLabelWidth">
-          <el-date-picker v-model="formData.LastCheckDate" type="date" placeholder="选择日期" style="width: 100%;">
+        <el-form-item label="上次检测日期"
+                      :label-width="formLabelWidth">
+          <el-date-picker v-model="formData.LastCheckDate"
+                          type="date"
+                          placeholder="选择日期"
+                          style="width: 100%;">
           </el-date-picker>
           <!--<el-input v-model="formData.LastCheckDate" autocomplete="off" v-if="formData.Id" readonly></el-input>-->
         </el-form-item>
-        <el-form-item label="检测周期" :label-width="formLabelWidth">
-          <el-input v-model="formData.Cycle" class="input-with-select" @change="CheckCycleDate" readonly>
-            <el-select v-model="formData.CycleUnit" slot="append" placeholder="请选择" style="width: 85px" disabled>
-              <el-option label="年" value="年"></el-option>
-              <el-option label="月" value="月"></el-option>
-              <el-option label="天" value="天"></el-option>
+        <el-form-item label="检测周期"
+                      :label-width="formLabelWidth">
+          <el-input v-model="formData.Cycle"
+                    class="input-with-select"
+                    @change="CheckCycleDate"
+                    readonly>
+            <el-select v-model="formData.CycleUnit"
+                       slot="append"
+                       placeholder="请选择"
+                       style="width: 85px"
+                       disabled>
+              <el-option label="年"
+                         value="年"></el-option>
+              <el-option label="月"
+                         value="月"></el-option>
+              <el-option label="天"
+                         value="天"></el-option>
             </el-select>
           </el-input>
         </el-form-item>
-        <el-form-item label="备注" :label-width="formLabelWidth">
-          <el-input v-model="formData.Remark" autocomplete="off"></el-input>
+        <el-form-item label="备注"
+                      :label-width="formLabelWidth">
+          <el-input v-model="formData.Remark"
+                    autocomplete="off"></el-input>
         </el-form-item>
+
+        <el-form-item label="附件上传"
+                      :label-width="formLabelWidth">
+          <el-upload multiple
+                     action=""
+                     ref="refmaintainlogattach"
+                     :http-request="uploadrequest"
+                     class="attach-uploader">
+            <el-button size="small"
+                       type="primary">点击上传</el-button>
+          </el-upload>
+        </el-form-item>
+
+        <el-form-item label="已有附件"
+                      :label-width="formLabelWidth" v-if="addoredittitle === '编辑'">
+          <el-table :data="FileItems"
+                    style="width: 100%"
+                    height="150px"
+                    size="mini"
+                    :show-header="false">
+            <el-table-column prop="FileName">
+            </el-table-column>
+            <el-table-column width="80">
+              <template slot-scope="scope">
+                <el-button size="mini"
+                           type="text"
+                           icon="el-icon-close"
+                           circle
+                           @click="handleDelete(scope.row)"></el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-form-item>
+
       </el-form>
-      <div slot="footer" class="dialog-footer">
+      <div slot="footer"
+           class="dialog-footer">
         <el-button @click="dialogFormVisible=false">取 消</el-button>
-        <el-button type="primary" @click="saveEntity" :loading="saveLoading">确 定</el-button>
+        <el-button type="primary"
+                   @click="saveEntity"
+                   :loading="saveLoading">确 定</el-button>
       </div>
     </el-dialog>
 
-
   </div>
 </template>
 <script>
-  import { mapGetters } from 'vuex'
-  import api from '@/api/lims/limscheckequipmentlist'
-  import positionApi from '@/api/lims/customerposition'
-
-  export default {
-    computed: {
-      ...mapGetters({
-        authUser: 'authUser'
-      })
-    },
-    name: 'CheckEquipmentList',
-
-    data () {
-      return {
-        statusOptions: [{
-          value: '-2',
-          label: '已过期'
-        }, {
-          value: '-1',
-          label: '一个月内到期'
-        }, {
-          value: '0',
-          label: '正常'
-        }],
-        detectionCycleList: [],
-        statusValue: '',
-        addoredittitle: '添加',
-        QueryProjectTypeId: '',
-        dialogVisible: false,
-        dialogFormVisible: false,
-        saveLoading: false,
-        selectNodeId: '',
-        // 列表数据
-        entityList: [],
-        PositionList: [],
-        // 分页参数
-        size: 10,
-        currentPage: 1,
-        currentItemCount: 0,
-        // 列表排序
-        Column: {
-          Order: '',
-          Prop: ''
+import { mapGetters } from 'vuex'
+import api from '@/api/lims/limscheckequipmentlist'
+import uploadajax from '@/assets/js/uploadajax.js'
+import positionApi from '@/api/lims/customerposition'
+import axios from 'axios'
+
+export default {
+  computed: {
+    ...mapGetters({
+      authUser: 'authUser'
+    })
+  },
+  name: 'CheckEquipmentList',
+
+  data () {
+    return {
+      statusOptions: [{
+        value: '-2',
+        label: '已过期'
+      }, {
+        value: '-1',
+        label: '一个月内到期'
+      }, {
+        value: '0',
+        label: '正常'
+      }],
+      detectionCycleList: [],
+      FileItems: [],
+      waituploads: [],
+      statusValue: '',
+      addoredittitle: '添加',
+      QueryProjectTypeId: '',
+      dialogVisible: false,
+      dialogFormVisible: false,
+      saveLoading: false,
+      selectNodeId: '',
+      // 列表数据
+      entityList: [],
+      PositionList: [],
+      // 分页参数
+      size: 10,
+      currentPage: 1,
+      currentItemCount: 0,
+      // 列表排序
+      Column: {
+        Order: '',
+        Prop: ''
+      },
+      // 查询时间
+      CreateOn: [new Date(new Date().getTime() - 30 * 24 * 60 * 60 * 1000), new Date()],
+      // 查询项
+      searchFormReset: {},
+      searchForm: {
+        Id: '',
+        DepartmentId: '',
+        OrderNo: '',
+        PositionCheckId: '',
+        PositionCheck: '',
+        PositionID: '',
+        Position: '',
+        CustNo: '',
+        Spec: '',
+        SpecId: '',
+        Manufacturer: '',
+        Status: ''
+
+      },
+      testTypeList: [],
+      projectTypeList: [],
+      customerTreeList: [],
+      tableColumns: [
+        {
+          prop: 'TemplateTypeName',
+          label: '设备类型',
+          width: 200,
+          sort: true
         },
-        // 查询时间
-        CreateOn: [new Date(new Date().getTime() - 30 * 24 * 60 * 60 * 1000), new Date()],
-        // 查询项
-        searchFormReset: {},
-        searchForm: {
-          Id: '',
-          DepartmentId: '',
-          OrderNo: '',
-          PositionCheckId: '',
-          PositionCheck: '',
-          PositionID: '',
-          Position: '',
-          CustNo: '',
-          Spec: '',
-          SpecId: '',
-          Manufacturer: '',
-          Status: ''
 
+        // {
+        //   prop: 'OrderNo',
+        //   label: '序号',
+        //   width: 100,
+        //   sort: true
+        // },
+
+        // {
+        //   prop: 'CustNo',
+        //   label: '编号',
+        //   width: 100,
+        //   sort: true
+        // },
+
+        {
+          prop: 'Spec',
+          label: '规格型号',
+          width: 100,
+          sort: true
         },
-        testTypeList: [],
-        projectTypeList: [],
-        customerTreeList: [],
-        tableColumns: [
-          {
-            prop: 'TemplateTypeName',
-            label: '设备类型',
-            width: 200,
-            sort: true
-          },
-
-          // {
-          //   prop: 'OrderNo',
-          //   label: '序号',
-          //   width: 100,
-          //   sort: true
-          // },
-
-          // {
-          //   prop: 'CustNo',
-          //   label: '编号',
-          //   width: 100,
-          //   sort: true
-          // },
-
-          {
-            prop: 'Spec',
-            label: '规格型号',
-            width: 100,
-            sort: true
-          },
-
-          {
-            prop: 'Manufacturer',
-            label: '制造厂家',
-            width: 200,
-            sort: true
-          },
-          {
-            prop: 'PositionCheck',
-            label: '检测地点',
-            width: 280,
-            sort: true
-          },
-
-          {
-            prop: 'Position',
-            label: '安装位置',
-            width: 200,
-            sort: true
-          },
-
-          {
-            prop: 'DepartmentName',
-            label: '所属单位',
-            width: 200,
-            sort: true
-          }
 
-        ],
-        formData: {
-          Id: 0,
-          DepartmentId: 0,
-          DepartmentName: '',
-          OrderNo: 0,
-          PositionCheckId: 0,
-          PositionCheck: '',
-          PositionID: 0,
-          Position: '',
-          CustNo: '',
-          DeviceName: '',
-          TemplateTypeId: 0,
-          TemplateTypeName: '',
-          Spec: '',
-          SpecId: '',
-          Manufacturer: '',
-          Status: '',
-          Remark: '',
-          Cycle: 0,
-          CycleUnit: '年',
-          LastCheckDate: new Date(),
-          CreateOn: '',
-          CreateUserId: '',
-          CreateBy: '',
-          ModifiedOn: '',
-          ModifiedUserId: '',
-          ModifiedBy: ''
+        {
+          prop: 'Manufacturer',
+          label: '制造厂家',
+          width: 200,
+          sort: true
         },
-        formLabelWidth: '120px',
-        orgtreeprops: {
-          value: 'id',
-          label: 'PositionName',
-          children: 'children'
+        {
+          prop: 'PositionCheck',
+          label: '检测地点',
+          width: 280,
+          sort: true
         },
-        customerForm: [],
-        CustomerId: 0
-      }
-    },
-    created () {
-      // 查询条件初始值备份
-      Object.assign(this.searchFormReset, this.searchForm)
-      // 查询列表
-      this.initDatas()
-      this.getProjectType()
-      this.getCustomerInfo()
-      // this.getDictOptions()
-      // 获得默认检测周期
-      this.getDetectionCycle()
-    },
-    methods: {
-      changeDetectionCycle (val) {
-        let _this = this
-        _this.formData.Cycle = 0
-        _this.formData.CycleUnit = '年'
-        for (let index = 0; index < _this.detectionCycleList.length; index++) {
-          if (_this.detectionCycleList[index].Pid === val) {
-            _this.formData.Cycle = _this.detectionCycleList[index].DetectionNum
-            _this.formData.CycleUnit = _this.detectionCycleList[index].DetectionUnit
-          }
+
+        {
+          prop: 'Position',
+          label: '安装位置',
+          width: 200,
+          sort: true
+        },
+
+        {
+          prop: 'DepartmentName',
+          label: '所属单位',
+          width: 200,
+          sort: true
         }
-      },
-      getDetectionCycle () {
-        let _this = this
-        const params = { _currentPage: 1, _size: 10000 }
 
-        _this.$axios.get('/items/getdetectionmodel/', { params })
-          .then(res => {
-            _this.detectionCycleList = res.data.items
-          })
-          .catch(err => {
-            console.error(err)
-          })
+      ],
+      formData: {
+        Id: 0,
+        DepartmentId: 0,
+        DepartmentName: '',
+        OrderNo: 0,
+        PositionCheckId: 0,
+        PositionCheck: '',
+        PositionID: 0,
+        Position: '',
+        CustNo: '',
+        DeviceName: '',
+        TemplateTypeId: 0,
+        TemplateTypeName: '',
+        Spec: '',
+        SpecId: '',
+        Manufacturer: '',
+        Status: '',
+        Remark: '',
+        Cycle: 0,
+        CycleUnit: '年',
+        uploadeds: [],
+        LastCheckDate: new Date()
+        // CreateOn: '',
+        // CreateUserId: '',
+        // CreateBy: '',
+        // ModifiedOn: '',
+        // ModifiedUserId: '',
+        // ModifiedBy: ''
       },
-      ProjectTypeChangeHandler () {
-        this.initDatas()
+      formLabelWidth: '120px',
+      orgtreeprops: {
+        value: 'id',
+        label: 'PositionName',
+        children: 'children'
       },
+      customerForm: [],
+      CustomerId: 0
+    }
+  },
+  created () {
+    // 查询条件初始值备份
+    Object.assign(this.searchFormReset, this.searchForm)
+    // 查询列表
+    this.initDatas()
+    this.getProjectType()
+    this.getCustomerInfo()
+    // this.getDictOptions()
+    // 获得默认检测周期
+    this.getDetectionCycle()
+  },
+  methods: {
+    handleDelete () {
 
-      ProjectTypeClearHandler () {
-        this.initDatas()
-      },
+    },
 
-      tableRowClassName ({row, column, rowIndex, columnIndex}) {
-        let lastDate = new Date(row.LastCheckDate)
-        let cycleDate = new Date()
-        if (row.CycleUnit === '年') {
-          cycleDate = new Date((lastDate.getFullYear() + row.Cycle * 1.0), lastDate.getMonth(), lastDate.getDate())
-        } else if (row.CycleUnit === '月') {
-          cycleDate = new Date(lastDate.getFullYear(), (lastDate.getMonth() + row.Cycle * 1.0), lastDate.getDate())
-        } else if (row.CycleUnit === '天') {
-          cycleDate = new Date(lastDate.getFullYear(), lastDate.getMonth(), (lastDate.getDate() + row.Cycle * 1.0))
-        }
-        let curDate = new Date()
-        let nearCycleDate = new Date(curDate.getFullYear(), (curDate.getMonth() + 1), curDate.getDate())
-        if (cycleDate < new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate()) && columnIndex === 1) {
-          return 'error-row'
-        } else if (cycleDate >= new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate()) && cycleDate <= nearCycleDate && columnIndex === 1) {
-          return 'warning-row'
-        } else if (cycleDate > nearCycleDate && columnIndex === 1) {
-          return 'normal-row'
+    changeDetectionCycle (val) {
+      let _this = this
+      _this.formData.Cycle = 0
+      _this.formData.CycleUnit = '年'
+      for (let index = 0; index < _this.detectionCycleList.length; index++) {
+        if (_this.detectionCycleList[index].Pid === val) {
+          _this.formData.Cycle = _this.detectionCycleList[index].DetectionNum
+          _this.formData.CycleUnit = _this.detectionCycleList[index].DetectionUnit
         }
-      },
+      }
+    },
+    getDetectionCycle () {
+      let _this = this
+      const params = { _currentPage: 1, _size: 10000 }
 
-      CheckCycleDate () {
-        this.formData.Cycle = this.formData.Cycle.replace(/[^0-9./]/g, '')
-      },
+      _this.$axios.get('/items/getdetectionmodel/', { params })
+        .then(res => {
+          _this.detectionCycleList = res.data.items
+        })
+        .catch(err => {
+          console.error(err)
+        })
+    },
+    ProjectTypeChangeHandler () {
+      this.initDatas()
+    },
 
-      orgtreeNodeClick (data) {
-        this.selectNodeId = data.id + ''
-        this.selectNodeName = data.PositionName + ''
+    ProjectTypeClearHandler () {
+      this.initDatas()
+    },
 
-        this.currentPage = 1
-        this.initDatas()
-      },
-      initDatas () {
-        // 分页及列表条件
-        let params = {
-          _currentPage: this.currentPage,
-          _size: this.size,
-          Order: this.Column.Order,
-          Prop: this.Column.Prop,
-          TemplateTypeId: this.QueryProjectTypeId + '',
-          PositionAllTypeId: this.selectNodeId + '',
-          statusValue: this.statusValue
-        }
-        let myCreateOn = []
-        // 解析时间
-        if (this.CreateOn && this.CreateOn.length === 2) {
-          this.CreateOn[1].setHours(23)
-          this.CreateOn[1].setMinutes(59)
-          this.CreateOn[1].setSeconds(59)
-          myCreateOn.push(this.formatDateTime(this.CreateOn[0]))
-          myCreateOn.push(this.formatDateTime(this.CreateOn[1]))
+    tableRowClassName ({ row, column, rowIndex, columnIndex }) {
+      let lastDate = new Date(row.LastCheckDate)
+      let cycleDate = new Date()
+      if (row.CycleUnit === '年') {
+        cycleDate = new Date((lastDate.getFullYear() + row.Cycle * 1.0), lastDate.getMonth(), lastDate.getDate())
+      } else if (row.CycleUnit === '月') {
+        cycleDate = new Date(lastDate.getFullYear(), (lastDate.getMonth() + row.Cycle * 1.0), lastDate.getDate())
+      } else if (row.CycleUnit === '天') {
+        cycleDate = new Date(lastDate.getFullYear(), lastDate.getMonth(), (lastDate.getDate() + row.Cycle * 1.0))
+      }
+      let curDate = new Date()
+      let nearCycleDate = new Date(curDate.getFullYear(), (curDate.getMonth() + 1), curDate.getDate())
+      if (cycleDate < new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate()) && columnIndex === 1) {
+        return 'error-row'
+      } else if (cycleDate >= new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate()) && cycleDate <= nearCycleDate && columnIndex === 1) {
+        return 'warning-row'
+      } else if (cycleDate > nearCycleDate && columnIndex === 1) {
+        return 'normal-row'
+      }
+    },
+
+    CheckCycleDate () {
+      this.formData.Cycle = this.formData.Cycle.replace(/[^0-9./]/g, '')
+    },
+
+    orgtreeNodeClick (data) {
+      this.selectNodeId = data.id + ''
+      this.selectNodeName = data.PositionName + ''
+
+      this.currentPage = 1
+      this.initDatas()
+    },
+    initDatas () {
+      // 分页及列表条件
+      let params = {
+        _currentPage: this.currentPage,
+        _size: this.size,
+        Order: this.Column.Order,
+        Prop: this.Column.Prop,
+        TemplateTypeId: this.QueryProjectTypeId + '',
+        PositionAllTypeId: this.selectNodeId + '',
+        statusValue: this.statusValue
+      }
+      let myCreateOn = []
+      // 解析时间
+      if (this.CreateOn && this.CreateOn.length === 2) {
+        this.CreateOn[1].setHours(23)
+        this.CreateOn[1].setMinutes(59)
+        this.CreateOn[1].setSeconds(59)
+        myCreateOn.push(this.formatDateTime(this.CreateOn[0]))
+        myCreateOn.push(this.formatDateTime(this.CreateOn[1]))
+      }
+      // 查询条件
+      Object.assign(params, this.searchForm)
+      // 访问接口
+      api.getList(myCreateOn.join(','), params, this.$axios).then(res => {
+        this.entityList = res.data.items
+        this.currentItemCount = res.data.currentItemCount
+      }).catch(err => {
+        console.error(err)
+      })
+    },
+
+    getDictOptions () {
+      api.getDictList(this.$axios).then(res => {
+        // this.dictOptions.customerList = res.data.items['customerList']
+        // this.dictOptions.projectList = res.data.items['projectList']
+
+      }).catch(err => {
+        console.error(err)
+      })
+    },
+
+    searchCommand (command) {
+      if (command === 'search') {
+        this.dialogVisible = true
+      } else if (command === 'clear') {
+        this.clearSearch()
+      }
+    },
+    // 列表排序功能
+    orderby (column) {
+      if (column.order === 'ascending') {
+        this.Column.Order = 'asc'
+      } else if (column.order === 'descending') {
+        this.Column.Order = 'desc'
+      }
+      this.Column.Prop = column.prop
+      this.initDatas()
+    },
+    clearSearch () {
+      Object.assign(this.searchForm, this.searchFormReset)
+      // this.searchForm = this.searchFormReset;
+      this.CreateOn = ''
+      this.initDatas()
+    },
+    handleSearch () {
+      this.currentPage = 1
+      this.dialogVisible = false
+      this.initDatas()
+    },
+    handleCurrentChange (value) {
+      this.currentPage = value
+      this.initDatas()
+    },
+    handleSizeChange (value) {
+      this.size = value
+      this.currentPage = 1
+      this.initDatas()
+    },
+    deleteConfirm (row) {
+      this.$confirm('此操作将永久删除该设备, 是否继续?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.deleteEntity(row)
+      })
+    },
+    deleteEntity (row) {
+      row.deleteConfirmFlag = false
+      api.deleteEntity(row.Id, this.$axios).then(res => {
+        if (res.data.code === 0) {
+          this.initDatas()
+          this.$message({
+            type: 'success',
+            message: res.data.message
+          })
+        } else {
+          this.$message({
+            type: 'warning',
+            message: res.data.message
+          })
         }
-        // 查询条件
-        Object.assign(params, this.searchForm)
-        // 访问接口
-        api.getList(myCreateOn.join(','), params, this.$axios).then(res => {
-          this.entityList = res.data.items
-          this.currentItemCount = res.data.currentItemCount
+      }).catch(err => {
+        console.error(err)
+      })
+    },
+
+    // 设备类型
+    getProjectType () {
+      let _this = this
+      _this.$axios.get('/testtype/testypetreeall', {})
+        .then(res => {
+          _this.testTypeList = res.data.items
+          if (!_this.testTypeList) {
+            return false
+          }
+          for (var i = 0; i < _this.testTypeList.length; i++) {
+            if (_this.testTypeList[i].ParentId == 0) {
+              _this.projectTypeList.push(_this.testTypeList[i])
+            }
+          }
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+        })
+    },
+
+    gettreelist () {
+      let params = {
+        CustomerId: this.CustomerId + ''
+      }
+      positionApi.customerPositionTree(params, this.$axios).then(res => {
+        this.customerTreeList = window.toolfun_gettreejson(res.data.items, 'Id', 'ParentId',
+          'Id,CustomerId,ParentId,PositionName,PositionCode,PositionType,PositionTypeId')
+      })
+        .catch(err => {
+          // handle error
+          console.error(err)
+        })
+    },
+    getCustomerInfo () {
+      let _this = this
+      this.$axios.get('customer/getcustomerbydepartid', {})
+        .then(res => {
+          _this.customerForm = res.data.items
+          _this.CustomerId = _this.customerForm.Id
+          _this.gettreelist()
         }).catch(err => {
           console.error(err)
         })
-      },
+    },
+
+    jstimehandle (val) {
+      if (val === '') {
+        return '----'
+      } else if (val === '0001-01-01T08:00:00+08:00') {
+        return '----'
+      } else if (val === '5000-01-01T23:59:59+08:00') {
+        return '永久'
+      } else {
+        val = val.replace('T', ' ')
+        return val.substring(0, 10)
+      }
+    },
+
+    formatDateTime (date) {
+      var y = date.getFullYear()
+      var m = date.getMonth() + 1
+      m = m < 10 ? ('0' + m) : m
+      var d = date.getDate()
+      d = d < 10 ? ('0' + d) : d
+      var h = date.getHours()
+      var minute = date.getMinutes()
+      minute = minute < 10 ? ('0' + minute) : minute
+      return y + '-' + m + '-' + d + ' ' + h + ':' + minute
+    },
 
-      getDictOptions () {
-        api.getDictList(this.$axios).then(res => {
-          // this.dictOptions.customerList = res.data.items['customerList']
-          // this.dictOptions.projectList = res.data.items['projectList']
+    NewEntity () {
+      let _this = this
+      this.addoredittitle = '添加'
+      this.dialogFormVisible = true
+      this.PositionList = []
+      this.$nextTick(() => {
+        _this.$refs.refmaintainlogattach.clearFiles()
+      })
+      this.waituploads = []
+      this.formData.uploadeds = []
+      this.formData.Id = 0
+      this.formData.Cycle = 0
+      this.formData.CycleUnit = '年'
+      this.formData.DepartmentId = 0
+      this.formData.DepartmentName = ''
+      this.formData.OrderNo = 0
+      this.formData.PositionCheckId = 0
+      this.formData.PositionCheck = ''
+      this.formData.PositionID = 0
+      this.formData.Position = ''
+      this.formData.CustNo = ''
+      this.formData.DeviceName = ''
+      // this.formData.TemplateTypeId = this.projectTypeList[0].Id
+      this.formData.TemplateTypeId = ''
 
+      this.formData.TemplateTypeName = ''
+      this.formData.Spec = ''
+      this.formData.SpecId = 0
+      this.formData.Manufacturer = ''
+      this.formData.Status = ''
+      this.formData.Remark = ''
+      this.formData.CreateOn = ''
+      this.formData.CreateUserId = 0
+      this.formData.CreateBy = ''
+      this.formData.ModifiedOn = ''
+      this.formData.ModifiedUserId = 0
+      this.formData.ModifiedBy = ''
+    },
+    exportExcel () {
+      let params = {
+        PositionAllTypeId: this.selectNodeId + ''
+      }
+      api.exportExcelAll(params, this.$axios).then(res => {
+        this.loading = false
+        window.location = 'http://' + res.data
+      })
+    },
+
+    handlePositionChange (value) {
+      this.formData.PositionCheckId = value[0]
+      this.formData.PositionID = value[1]
+    },
+    ShowEntityDialog (entityId) {
+      this.addoredittitle = '编辑'
+      this.$nextTick(() => {
+        this.$refs.refmaintainlogattach.clearFiles()
+      })
+      this.waituploads = []
+      this.formData.uploadeds = []
+      this.initEntity(entityId)
+      this.dialogFormVisible = true
+    },
+    initEntity (entityId) {
+      if (entityId) {
+        api.getEntity(entityId, this.$axios).then(res => {
+          this.formData = res.data.Items
+          this.PositionList = [this.formData.PositionCheckId, this.formData.PositionID]
+          this.FileItems = res.data.FileItems
         }).catch(err => {
           console.error(err)
         })
-      },
+      }
+    },
 
-      searchCommand (command) {
-        if (command === 'search') {
-          this.dialogVisible = true
-        } else if (command === 'clear') {
-          this.clearSearch()
-        }
-      },
-      // 列表排序功能
-      orderby (column) {
-        if (column.order === 'ascending') {
-          this.Column.Order = 'asc'
-        } else if (column.order === 'descending') {
-          this.Column.Order = 'desc'
-        }
-        this.Column.Prop = column.prop
-        this.initDatas()
-      },
-      clearSearch () {
-        Object.assign(this.searchForm, this.searchFormReset)
-        // this.searchForm = this.searchFormReset;
-        this.CreateOn = ''
-        this.initDatas()
-      },
-      handleSearch () {
-        this.currentPage = 1
-        this.dialogVisible = false
-        this.initDatas()
-      },
-      handleCurrentChange (value) {
-        this.currentPage = value
-        this.initDatas()
-      },
-      handleSizeChange (value) {
-        this.size = value
-        this.currentPage = 1
-        this.initDatas()
-      },
-      deleteConfirm (row) {
-        this.$confirm('此操作将永久删除该设备, 是否继续?', '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          this.deleteEntity(row)
-        })
-      },
-      deleteEntity (row) {
-        row.deleteConfirmFlag = false
-        api.deleteEntity(row.Id, this.$axios).then(res => {
-          if (res.data.code === 0) {
-            this.initDatas()
-            this.$message({
-              type: 'success',
-              message: res.data.message
+    uploadrequest (option) {
+      let _this = this
+      axios.post(process.env.upfilehost, {})
+        .then(function (res) {
+          if (res.data && res.data.fid && res.data.fid !== '') {
+            option.action = `http://${res.data.url}/${res.data.fid}`
+            _this.waituploads.push({
+              uid: option.file.uid,
+              url: res.data.publicUrl,
+              fid: res.data.fid
             })
+            uploadajax(option)
           } else {
-            this.$message({
+            _this.$message({
               type: 'warning',
-              message: res.data.message
+              message: '未上传成功!请刷新界面重新上传!'
             })
           }
-        }).catch(err => {
-          console.error(err)
         })
-      },
+        .catch(function (error) {
+          console.log(error)
+          _this.$message({
+            type: 'warning',
+            message: '未上传成功!请重新上传!'
+          })
+        })
+    },
+    // 判断附件是否上传成功
+    attachissuccess () {
+      if (this.$refs.refmaintainlogattach.uploadFiles && this.$refs.refmaintainlogattach.uploadFiles.length > 0) {
+        for (let i = 0; i < this.$refs.refmaintainlogattach.uploadFiles.length; i++) {
+          if (this.$refs.refmaintainlogattach.uploadFiles[i].status !== 'success') {
+            return false
+          }
+        }
+      }
+      return true
+    },
 
-      // 设备类型
-      getProjectType () {
-        let _this = this
-        _this.$axios.get('/testtype/testypetreeall', {})
-          .then(res => {
-            _this.testTypeList = res.data.items
-            if (!_this.testTypeList) {
-              return false
-            }
-            for (var i = 0; i < _this.testTypeList.length; i++) {
-              if (_this.testTypeList[i].ParentId == 0) {
-                _this.projectTypeList.push(_this.testTypeList[i])
+    // 获取上传成功的附件
+    getattachissuccess () {
+      this.formData.uploadeds = []
+      if (this.$refs.refmaintainlogattach.uploadFiles && this.$refs.refmaintainlogattach.uploadFiles.length > 0) {
+        for (let i = 0; i < this.$refs.refmaintainlogattach.uploadFiles.length; i++) {
+          if (this.$refs.refmaintainlogattach.uploadFiles[i].status === 'success') {
+            for (let j = 0; j < this.waituploads.length; j++) {
+              if (this.waituploads[j].uid === this.$refs.refmaintainlogattach.uploadFiles[i].uid) {
+                this.formData.uploadeds.push({
+                  Host: this.waituploads[j].url,
+                  FileId: this.waituploads[j].fid,
+                  FileSize: this.$refs.refmaintainlogattach.uploadFiles[i].size,
+                  FileName: this.$refs.refmaintainlogattach.uploadFiles[i].name,
+                  FileURL: this.waituploads[j].url + '/' + this.waituploads[j].fid
+                })
               }
             }
-          })
-          .catch(err => {
-            // handle error
-            console.error(err)
-          })
-      },
-
-      gettreelist () {
-        let params = {
-          CustomerId: this.CustomerId + ''
+          }
         }
-        positionApi.customerPositionTree(params, this.$axios).then(res => {
-          this.customerTreeList = window.toolfun_gettreejson(res.data.items, 'Id', 'ParentId',
-            'Id,CustomerId,ParentId,PositionName,PositionCode,PositionType,PositionTypeId')
+      }
+    },
+    // 保存信息
+    saveEntity () {
+      if (this.$refs.refProjectTypeId.selectedLabel <= 0) {
+        this.$message({
+          type: 'warning',
+          message: '请选择设备类型'
         })
-          .catch(err => {
-            // handle error
-            console.error(err)
-          })
-      },
-      getCustomerInfo () {
-        let _this = this
-        this.$axios.get('customer/getcustomerbydepartid', {})
-          .then(res => {
-            _this.customerForm = res.data.items
-            _this.CustomerId = _this.customerForm.Id
-            _this.gettreelist()
-          }).catch(err => {
-            console.error(err)
-          })
-      },
-
-      jstimehandle (val) {
-        if (val === '') {
-          return '----'
-        } else if (val === '0001-01-01T08:00:00+08:00') {
-          return '----'
-        } else if (val === '5000-01-01T23:59:59+08:00') {
-          return '永久'
-        } else {
-          val = val.replace('T', ' ')
-          return val.substring(0, 10)
-        }
-      },
+        return
+      }
 
-      formatDateTime (date) {
-        var y = date.getFullYear()
-        var m = date.getMonth() + 1
-        m = m < 10 ? ('0' + m) : m
-        var d = date.getDate()
-        d = d < 10 ? ('0' + d) : d
-        var h = date.getHours()
-        var minute = date.getMinutes()
-        minute = minute < 10 ? ('0' + minute) : minute
-        return y + '-' + m + '-' + d + ' ' + h + ':' + minute
-      },
+      if (this.PositionList.length !== 2) {
+        this.$message({
+          type: 'warning',
+          message: '请选择安装位置'
+        })
+        return
+      }
 
-      NewEntity () {
-        this.addoredittitle = '添加'
-        this.dialogFormVisible = true
-        this.PositionList = []
-        this.formData.Id = 0
-        this.formData.Cycle = 0
-        this.formData.CycleUnit = '年'
-        this.formData.DepartmentId = 0
-        this.formData.DepartmentName = ''
-        this.formData.OrderNo = 0
-        this.formData.PositionCheckId = 0
-        this.formData.PositionCheck = ''
-        this.formData.PositionID = 0
-        this.formData.Position = ''
-        this.formData.CustNo = ''
-        this.formData.DeviceName = ''
-        // this.formData.TemplateTypeId = this.projectTypeList[0].Id
-        this.formData.TemplateTypeId = ''
-        this.formData.TemplateTypeName = ''
-        this.formData.Spec = ''
-        this.formData.SpecId = 0
-        this.formData.Manufacturer = ''
-        this.formData.Status = ''
-        this.formData.Remark = ''
-        this.formData.CreateOn = ''
-        this.formData.CreateUserId = 0
-        this.formData.CreateBy = ''
-        this.formData.ModifiedOn = ''
-        this.formData.ModifiedUserId = 0
-        this.formData.ModifiedBy = ''
-      },
-      exportExcel () {
-        let params = {
-          PositionAllTypeId: this.selectNodeId + ''
+      // 是否有上传附件判断
+      if (this.$refs.refmaintainlogattach.uploadFiles && this.$refs.refmaintainlogattach.uploadFiles.length > 0) {
+        // 上传附件是否完成判断
+        if (!this.attachissuccess()) {
+          this.$message.error('有文件未成功上传!不能保存数据')
+          return
         }
-        api.exportExcelAll(params, this.$axios).then(res => {
-          this.loading = false
-          window.location = 'http://' + res.data
-        })
-      },
+        this.getattachissuccess()
+      } else {
+        // this.$message({
+        //   type: 'warning',
+        //   message: '请选择要上传的文件'
+        // })
+        // return
+      }
 
-      handlePositionChange (value) {
-        this.formData.PositionCheckId = value[0]
-        this.formData.PositionID = value[1]
-      },
-      ShowEntityDialog (entityId) {
-        this.addoredittitle = '编辑'
-        this.initEntity(entityId)
-        this.dialogFormVisible = true
-      },
-      initEntity (entityId) {
-        if (entityId) {
-          api.getEntity(entityId, this.$axios).then(res => {
-            this.formData = res.data
-            this.PositionList = [ this.formData.PositionCheckId, this.formData.PositionID ]
-          }).catch(err => {
-            console.error(err)
-          })
+      this.$refs['EntityForm'].validate((valid) => {
+        if (valid) {
+          this.saveLoading = true
+          this.formData.TemplateTypeName = this.$refs.refProjectTypeId.selectedLabel + ''
+          this.formData.PositionCheck = this.$refs.cascaderPosition.presentText.split('/')[0]
+          this.formData.Position = this.$refs.cascaderPosition.presentText.split('/')[1]
+          this.formData.Cycle = parseFloat(this.formData.Cycle)
+          if (!this.formData.Id) {
+            this.addEntity()
+          } else {
+            this.updateEntity()
+          }
+        } else {
+          return false
         }
-      },
+      })
+    },
 
-      // 保存信息
-      saveEntity () {
-        if (this.$refs.refProjectTypeId.selectedLabel <= 0) {
+    addEntity () {
+      api.addEntity(this.formData, this.$axios).then(res => {
+        if (res.data.code === 0) {
+          // 保存成功后,初始化数据,变成修改
+          this.formData.Id = res.data.item
+          this.dialogFormVisible = false
+          this.initDatas()
+          this.$message({
+            type: 'success',
+            message: res.data.message
+          })
+        } else {
           this.$message({
             type: 'warning',
-            message: '请选择设备类型'
+            message: res.data.message
           })
-          return
         }
+        this.saveLoading = false
+      }).catch(err => {
+        console.error(err)
+      })
+    },
 
-        if (this.PositionList.length !== 2) {
+    updateEntity () {
+      api.updateEntity(this.formData.Id, this.formData, this.$axios).then(res => {
+        if (res.data.code === 0) {
+          // 保存成功后,初始化数据,变成修改
+          this.dialogFormVisible = false
+          this.initDatas()
+          this.$message({
+            type: 'success',
+            message: res.data.message
+          })
+        } else {
           this.$message({
             type: 'warning',
-            message: '请选择安装位置'
+            message: res.data.message
           })
-          return
         }
-        this.$refs['EntityForm'].validate((valid) => {
-          if (valid) {
-            this.saveLoading = true
-            this.formData.TemplateTypeName = this.$refs.refProjectTypeId.selectedLabel + ''
-            this.formData.PositionCheck = this.$refs.cascaderPosition.presentText.split('/')[0]
-            this.formData.Position = this.$refs.cascaderPosition.presentText.split('/')[1]
-            this.formData.Cycle = parseFloat(this.formData.Cycle)
-            if (!this.formData.Id) {
-              this.addEntity()
-            } else {
-              this.updateEntity()
-            }
-          } else {
-            return false
-          }
-        })
-      },
-
-      addEntity () {
-        api.addEntity(this.formData, this.$axios).then(res => {
-          if (res.data.code === 0) {
-            // 保存成功后,初始化数据,变成修改
-            this.formData.Id = res.data.item
-            this.dialogFormVisible = false
-            this.initDatas()
-            this.$message({
-              type: 'success',
-              message: res.data.message
-            })
-          } else {
-            this.$message({
-              type: 'warning',
-              message: res.data.message
-            })
-          }
-          this.saveLoading = false
-        }).catch(err => {
-          console.error(err)
-        })
-      },
-
-      updateEntity () {
-        api.updateEntity(this.formData.Id, this.formData, this.$axios).then(res => {
-          if (res.data.code === 0) {
-            // 保存成功后,初始化数据,变成修改
-            this.dialogFormVisible = false
-            this.initDatas()
-            this.$message({
-              type: 'success',
-              message: res.data.message
-            })
-          } else {
-            this.$message({
-              type: 'warning',
-              message: res.data.message
-            })
-          }
-          this.saveLoading = false
-        }).catch(err => {
-          console.error(err)
-        })
-      }
+        this.saveLoading = false
+      }).catch(err => {
+        console.error(err)
+      })
     }
   }
+}
 </script>
 
 <style lang='scss'>
-  .el-pagination {
-    margin: 1rem 0 2rem;
-    text-align: right;
-  }
+.el-pagination {
+  margin: 1rem 0 2rem;
+  text-align: right;
+}
 
-  .el-table .warning-row {
-    color: yellow;
-  }
+.el-table .warning-row {
+  color: yellow;
+}
 
-  .el-table .error-row {
-    color: red;
-  }
+.el-table .error-row {
+  color: red;
+}
 
-   .el-table .normal-row {
-    color: green;
-  }
+.el-table .normal-row {
+  color: green;
+}
 
-  .bottom {
-    // margin-top: 13px;
-    line-height: 12px;
-  }
+.bottom {
+  // margin-top: 13px;
+  line-height: 12px;
+}
 
-  .clearfix:before,
-  .clearfix:after {
-      display: table;
-      content: "";
-  }
+.clearfix:before,
+.clearfix:after {
+  display: table;
+  content: "";
+}
 
-  .clearfix:after {
-      clear: both
-  }
+.clearfix:after {
+  clear: both;
+}
 </style>