瀏覽代碼

年审添加资质

lining 5 年之前
父節點
當前提交
42c1d58c91

+ 118 - 0
src/dashoo.cn/backend/api/controllers/oilsupplier/annualaudit.go

@@ -1494,4 +1494,122 @@ func (this *AnnualAuditController) DeleteNewFile() {
 		this.Data["json"] = &errinfo
 		this.ServeJSON()
 	}
+}
+
+// @Title 删除添加的资质
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /deleteaddfile/:Id [delete]
+func (this *AnnualAuditController) DeleteAddFile() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	svc := infochange.GetInfoChangeService(utils.DBE)
+
+	where := "FileId=" + Id
+	err := svc.DeleteEntityBytbl(OilAnnualChangeDetailName, where)
+
+	where1 := "Id=" + Id
+	err = svc.DeleteEntityBytbl(OilSupplierFileName, where1)
+
+
+	if err == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 添加资质
+// @Description 添加资质
+// @Success	200	{object}
+// @router /addqualchange/:id [post]
+func (this *AnnualAuditController) AddAppChange() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model annualaudit.OilAnnualChangeDetail
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+
+	svc := qualchange.GetQualChangeService(utils.DBE)
+
+	var file supplierfile.OilSupplierFile
+	where := "SupplierId = '" + strconv.Itoa(model.SupplierId) + "' and NeedFileType='" + model.NeedFileType + "'"
+	has := svc.GetEntity(&file, where)
+
+	var tableHeader tableheader.BaseTableheader
+	where1 := "Name = '" + model.NeedFileType + "'"
+	svc.GetEntityByWhere(BaseTableHeader, where1, &tableHeader)
+
+	if has {
+		errinfo.Message = "操作失败!不能重复添加"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	file.SupplierId = model.SupplierId
+	file.SupplierTypeCode = model.SupplierTypeCode
+	file.IsManuf = tableHeader.IsManuf
+	file.NeedFileType = model.NeedFileType
+	file.FileType = 0
+	file.SupType = 2
+	file.CreateOn = time.Now()
+	file.CreateUserId, _ = strconv.Atoi(this.User.Id)
+	file.CreateBy = this.User.Realname
+
+	svc.InsertEntity(&file)
+
+	model.ParentId, _ = strconv.Atoi(id)
+	model.FileId = file.Id
+	model.FileUrl = strings.Trim(model.FileUrl, "$")
+	model.FileName = strings.Trim(model.FileName, "$")
+
+	var err error
+	var qualdetaimodel []annualaudit.OilAnnualChangeDetail
+
+	qdwhere := " SupplierId = " + utils.ToStr(model.SupplierId) + " and FileId = " + utils.ToStr(file.Id) + " and ParentId=" + id
+	svc.GetEntitysByWhere(OilAnnualChangeDetailName, qdwhere, &qualdetaimodel)
+	if len(qualdetaimodel) == 0 {
+		model.CreateOn = time.Now()
+		model.CreateBy = this.User.Realname
+		model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+		_, err = svc.InsertEntityBytbl(OilAnnualChangeDetailName, &model)
+	} else {
+		err = svc.UpdateEntityBywheretbl(OilAnnualChangeDetailName, &model, []string{"OldEffectDate", "FileUrl", "FileName", "OtherRemark"}, qdwhere)
+	}
+
+	if err == nil {
+		errinfo.Message = "操作成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
 }

+ 6 - 0
src/dashoo.cn/frontend_web/src/api/oilsupplier/annualaudit.js

@@ -140,5 +140,11 @@ export default {
       url: '/annualaudit/deletenewfile/' + Id,
       method: 'delete'
     })
+  },
+  deleteAddfile (Id, myAxios) {
+    return myAxios({
+      url: '/annualaudit/deleteaddfile/' + Id,
+      method: 'delete'
+    })
   }
 }

+ 219 - 1
src/dashoo.cn/frontend_web/src/pages/oilsupplier/annualaudit/_opera/bassicoperation.vue

@@ -603,12 +603,16 @@
           <el-card class="box-card" style="margin-top: 10px;">
             <div slot="header" class="clearfix">
               <span style="font-weight: bold">企业资质</span>
+              <el-button style="float: right; padding: 3px 0" type="text" @click="showDialog" >添加</el-button>
             </div>
             <el-table :data="subfileList" border>
               <el-table-column label="操作" width="150" align="center" fixed v-if="Status <= 0">
                 <template slot-scope="scope">
                   <el-button type="primary" plain size="mini" title="文件变更" @click="openDialog(scope.row)">
                     变更</el-button>
+                  <el-button type="danger" plain size="mini" title="文件删除" @click="delFile(scope.row)"
+                             v-if="scope.row.FileType == 0 && scope.row.OldFileUrl == ''">
+                    删除</el-button>
                 </template>
               </el-table-column>
               <el-table-column prop="NeedFileType" label="文件分类" show-overflow-tooltip></el-table-column>
@@ -838,6 +842,47 @@
         <el-button type="primary" @click="makesure()">确 定</el-button>
       </div>
     </el-dialog>
+
+    <el-dialog title="新增文件" :visible.sync="newVisible" top="5vh">
+      <el-form ref="newSubfileForm" :model="newSubfileForm" label-width="100px" :rules="newrules">
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="资质名称" prop="NeedFileType">
+              <el-select v-model="newSubfileForm.NeedFileType" placeholder="请输文件类型" size="medium">
+                <el-option v-for="item in dynamicTableColumns" :key="item.prop" :label="item.label" :value="item.label">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="有效日期" prop="EffectDate">
+              <el-date-picker style="width: 100%" v-model="newSubfileForm.EffectDate" type="date" placeholder="请选择有效日期">
+              </el-date-picker>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="描述">
+              <el-input v-model="newSubfileForm.OtherRemark" type="textarea" :rows=3 placeholder="请输入备注信息"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="资质文件">
+              <el-upload multiple style="margin-top: 10px;" action="" ref="newrefuploadattach"
+                         :http-request="uploadrequest" class="attach-uploader" :before-upload="newbeforeAvatarUpload">
+                <i class="el-icon-plus attach-uploader-icon"></i>
+                <div slot="tip" class="el-upload__tip">大小为512KB-5MB
+                </div>
+              </el-upload>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer" style="margin-top:-30px;">
+        <el-button @click="newVisible = false">取 消</el-button>
+        <el-button type="primary" @click="makeNewSure()">确 定</el-button>
+      </div>
+    </el-dialog>
+
     <choose-auditor ref="chooseAuditor" @close="setAuditer" @hideChooseAuditer="chooseAuditorVisible=false"
       :visible="chooseAuditorVisible"></choose-auditor>
     <choose-auditor-fen ref="chooseAuditorFen" @close="setAuditerFen" @hideChooseAuditer="chooseAuditorVisibleFen=false"
@@ -870,6 +915,7 @@ import apiCert from '@/api/oilsupplier/suppliercert'
   import axios from 'axios'
   import uploadajax from '@/assets/js//uploadajax.js'
   import fileapi from '@/api/oilsupplier/supplierfile'
+  import setapi from '@/api/oilsupplier/oilclassorgset'
 
   export default {
     computed: {
@@ -1038,6 +1084,34 @@ import apiCert from '@/api/oilsupplier/suppliercert'
         }
       }
       return {
+        newVisible: false,
+        newSubfileForm: {
+          Id: '',
+          SupplierId: '',
+          SupplierTypeCode: '02',
+          SupplierCertSubId: '',
+          CertSubName: '',
+          SupType: 2,
+          NeedFileType: '',
+          NeedFileCode: '',
+          FileType: 66,
+          FileExt: '',
+          FileName: '',
+          EffectDate: new Date(),
+          FileUrl: '',
+          OtherRemark: '',
+          Remark: '',
+          IsDelete: 0,
+          FileUrlList: []
+        },
+        dynamicTableColumns: [],
+        newrules: {
+          NeedFileType: [
+            {required: true, message: '资质名称不能为空', trigger: 'blur'}
+          ],
+          EffectDate:
+            [{ required: true, validator: effectDate, trigger: 'change' }]
+        },
         IsCompanyUser: 0,
         totalTab: 4,
         activeName: '0',
@@ -1513,8 +1587,153 @@ import apiCert from '@/api/oilsupplier/suppliercert'
       }
       // this.orgtreeChange(this.majorDept)
       this.getsubfile()
+      this.initTableHeader()
+      this.getFileDictOptions()
     },
     methods: {
+      getFileDictOptions () {
+        api.getDictList(this.$axios).then(res => {
+          this.yasuoname = res.data.items['YaSuoName']
+        }).catch(err => {
+          console.error(err)
+        })
+      },
+      // 添加资质
+      initTableHeader () {
+        setapi.initBbTableHeader(this.$axios).then(res => {
+          this.dynamicTableColumns = res.data.items
+        })
+      },
+      newbeforeAvatarUpload (file) {
+        let isLt512K = file.size / 1024 < 512
+        if (isLt512K) {
+          this.$message.error('上传文件大小不能小于 512KB!')
+          return false
+        }
+        if (this.newSubfileForm.NeedFileType != this.yasuoname) {
+          if (file.type.indexOf('image') < 0) {
+            this.$message.error('上传图片!')
+            return false
+          }
+          let isLt50m = file.size / 1024 / 1024 / 5 < 1
+          if (!isLt50m) {
+            this.$message.error('上传文件大小不能超过 5MB!')
+            return false
+          }
+          return true
+        } else {
+          if (file.name.indexOf('.rar') < 0 && file.name.indexOf('.zip') < 0) {
+            this.$message.error('文件格式必须为rar或zip')
+            return false
+          }
+          return true
+        }
+      },
+      makeNewSure () {
+        if (this.$refs.newrefuploadattach.uploadFiles && this.$refs.newrefuploadattach.uploadFiles.length > 0) {
+          // 上传附件是否完成判断
+          if (!this.newattachissuccess()) {
+            this.$message.error('有附件未成功上传!不能保存数据')
+            return
+          }
+          this.newgetattachissuccess()
+          this.addSubfile()
+        } else {
+          this.$message({
+            type: 'warning',
+            message: '请上传文件!'
+          })
+        }
+      },
+      addSubfile () {
+        let _this = this
+        _this.newSubfileForm.SupplierId = parseInt(_this.serviceId)
+        _this.newSubfileForm.SupplierCertId = parseInt(_this.certId)
+
+        this.$refs['newSubfileForm'].validate((valid) => {
+          if (valid) {
+            _this.$axios.post('/annualaudit/addqualchange/' + _this.annualId, _this.newSubfileForm)
+              .then(res => {
+                if (res.data.code === 0) {
+                  _this.$message({
+                    type: 'success',
+                    message: res.data.message
+                  })
+                  this.newVisible = false
+                  this.getsubfile()
+                  this.$refs.newrefuploadattach.uploadFiles = []
+                } else {
+                  _this.$message({
+                    type: 'warning',
+                    message: res.data.message
+                  })
+                }
+              })
+              .catch(err => {
+                console.error(err)
+              })
+          }
+        })
+      },
+      newattachissuccess () {
+        if (this.$refs.newrefuploadattach.uploadFiles && this.$refs.newrefuploadattach.uploadFiles.length > 0) {
+          for (let i = 0; i < this.$refs.newrefuploadattach.uploadFiles.length; i++) {
+            if (this.$refs.newrefuploadattach.uploadFiles[i].status !== 'success') {
+              return false
+            }
+          }
+        }
+        return true
+      },
+      newgetattachissuccess () {
+        this.newSubfileForm.FileUrl = ''
+        this.newSubfileForm.FileName = ''
+        if (this.$refs.newrefuploadattach.uploadFiles && this.$refs.newrefuploadattach.uploadFiles.length > 0) {
+          for (let i = 0; i < this.$refs.newrefuploadattach.uploadFiles.length; i++) {
+            if (this.$refs.newrefuploadattach.uploadFiles[i].status === 'success') {
+              for (let j = 0; j < this.waituploads.length; j++) {
+                if (this.waituploads[j].uid === this.$refs.newrefuploadattach.uploadFiles[i].uid) {
+                  this.newSubfileForm.FileUrl +=
+                    `${this.waituploads[j].url}/${this.waituploads[j].fid}|${this.$refs.newrefuploadattach.uploadFiles[i].name}$`
+                  this.newSubfileForm.FileName += `${this.$refs.newrefuploadattach.uploadFiles[i].name}$`
+                }
+              }
+            }
+          }
+        }
+      },
+      delFile (row) {
+        let confirmmsg = '此操作将彻底删除该数据, 是否继续?'
+        this.$confirm(confirmmsg, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+          .then(() => {
+            annualapi.deleteAddfile(row.Id, this.$axios).then(res => {
+              if (res.data.code === 0) {
+                this.$message({
+                  type: 'success',
+                  message: res.data.message
+                })
+                this.getsubfile()
+              } else {
+                this.$message({
+                  type: 'warning',
+                  message: res.data.message
+                })
+              }
+            })
+          })
+          .catch(() => {})
+      },
+      showDialog () {
+        this.newVisible = true
+        this.newSubfileForm.NeedFileType = ''
+        this.newSubfileForm.EffectDate = ''
+        this.newSubfileForm.OtherRemark = ''
+      },
+
       // Tab
       nextTab () {
         let valid = true
@@ -2419,7 +2638,6 @@ import apiCert from '@/api/oilsupplier/suppliercert'
             MInfoId: this.annualId,
             InfochangeForm: this.infochangeItemList
           }
-          console.log('----', AllInfochangeItemList)
           annualapi.addInfoChangeItemCh(AllInfochangeItemList, this.$axios).then(res => {
             if (res.data.code === 0) {
               // 保存成功后,初始化数据,变成修改

+ 210 - 0
src/dashoo.cn/frontend_web/src/pages/oilsupplier/annualaudit/_opera/goodsoperation.vue

@@ -691,12 +691,16 @@
           <el-card class="box-card" style="margin-top: 10px;">
             <div slot="header" class="clearfix">
               <span style="font-weight: bold">企业资质</span>
+              <el-button style="float: right; padding: 3px 0" type="text" @click="showDialog" >添加</el-button>
             </div>
             <el-table :data="subfileList" border>
               <el-table-column label="操作" width="150" align="center" fixed v-if="Status <= 0">
                 <template slot-scope="scope">
                   <el-button type="primary" plain size="mini" title="文件变更" @click="openDialog(scope.row)">
                     变更</el-button>
+                  <el-button type="danger" plain size="mini" title="文件删除" @click="delFile(scope.row)"
+                             v-if="scope.row.FileType == 0 && scope.row.OldFileUrl == ''">
+                    删除</el-button>
                 </template>
               </el-table-column>
               <el-table-column prop="NeedFileType" label="文件分类" show-overflow-tooltip></el-table-column>
@@ -926,6 +930,46 @@
         <el-button type="primary" @click="makesure()">确 定</el-button>
       </div>
     </el-dialog>
+    <el-dialog title="新增文件" :visible.sync="newVisible" top="5vh">
+      <el-form ref="newSubfileForm" :model="newSubfileForm" label-width="100px" :rules="newrules">
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="资质名称" prop="NeedFileType">
+              <el-select v-model="newSubfileForm.NeedFileType" placeholder="请输文件类型" size="medium">
+                <el-option v-for="item in dynamicTableColumns" :key="item.prop" :label="item.label" :value="item.label">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="有效日期" prop="EffectDate">
+              <el-date-picker style="width: 100%" v-model="newSubfileForm.EffectDate" type="date" placeholder="请选择有效日期">
+              </el-date-picker>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="描述">
+              <el-input v-model="newSubfileForm.OtherRemark" type="textarea" :rows=3 placeholder="请输入备注信息"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="资质文件">
+              <el-upload multiple style="margin-top: 10px;" action="" ref="newrefuploadattach"
+                         :http-request="uploadrequest" class="attach-uploader" :before-upload="newbeforeAvatarUpload">
+                <i class="el-icon-plus attach-uploader-icon"></i>
+                <div slot="tip" class="el-upload__tip">大小为512KB-5MB
+                </div>
+              </el-upload>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer" style="margin-top:-30px;">
+        <el-button @click="newVisible = false">取 消</el-button>
+        <el-button type="primary" @click="makeNewSure()">确 定</el-button>
+      </div>
+    </el-dialog>
+
     <choose-auditor ref="chooseAuditor" @close="setAuditer" @hideChooseAuditer="chooseAuditorVisible=false"
       :visible="chooseAuditorVisible"></choose-auditor>
     <choose-auditor-fen ref="chooseAuditorFen" @close="setAuditerFen" @hideChooseAuditer="chooseAuditorVisibleFen=false"
@@ -959,6 +1003,7 @@
   import axios from 'axios'
   import uploadajax from '@/assets/js//uploadajax.js'
   import fileapi from '@/api/oilsupplier/supplierfile'
+  import setapi from '@/api/oilsupplier/oilclassorgset'
 
   export default {
     computed: {
@@ -1140,6 +1185,34 @@
         }
       }
       return {
+        newVisible: false,
+        newSubfileForm: {
+          Id: '',
+          SupplierId: '',
+          SupplierTypeCode: '01',
+          SupplierCertSubId: '',
+          CertSubName: '',
+          SupType: 2,
+          NeedFileType: '',
+          NeedFileCode: '',
+          FileType: 66,
+          FileExt: '',
+          FileName: '',
+          EffectDate: new Date(),
+          FileUrl: '',
+          OtherRemark: '',
+          Remark: '',
+          IsDelete: 0,
+          FileUrlList: []
+        },
+        dynamicTableColumns: [],
+        newrules: {
+          NeedFileType: [
+            {required: true, message: '资质名称不能为空', trigger: 'blur'}
+          ],
+          EffectDate:
+            [{ required: true, validator: effectDate, trigger: 'change' }]
+        },
         IsCompanyUser: 0,
         totalTab: 4,
         activeName: '0',
@@ -1618,8 +1691,145 @@
       }
       this.orgtreeChange(this.majorDept)
       this.getsubfile()
+      this.initTableHeader()
     },
     methods: {
+      // 添加资质
+      initTableHeader () {
+        setapi.initGoodTableHeader(this.$axios).then(res => {
+          this.dynamicTableColumns = res.data.items
+        })
+      },
+      newbeforeAvatarUpload (file) {
+        let isLt512K = file.size / 1024 < 512
+        if (isLt512K) {
+          this.$message.error('上传文件大小不能小于 512KB!')
+          return false
+        }
+        if (this.newSubfileForm.NeedFileType != this.yasuoname) {
+          if (file.type.indexOf('image') < 0) {
+            this.$message.error('上传图片!')
+            return false
+          }
+          let isLt50m = file.size / 1024 / 1024 / 5 < 1
+          if (!isLt50m) {
+            this.$message.error('上传文件大小不能超过 5MB!')
+            return false
+          }
+          return true
+        } else {
+          if (file.name.indexOf('.rar') < 0 && file.name.indexOf('.zip') < 0) {
+            this.$message.error('文件格式必须为rar或zip')
+            return false
+          }
+          return true
+        }
+      },
+      makeNewSure () {
+        if (this.$refs.newrefuploadattach.uploadFiles && this.$refs.newrefuploadattach.uploadFiles.length > 0) {
+          // 上传附件是否完成判断
+          if (!this.newattachissuccess()) {
+            this.$message.error('有附件未成功上传!不能保存数据')
+            return
+          }
+          this.newgetattachissuccess()
+          this.addSubfile()
+        } else {
+          this.$message({
+            type: 'warning',
+            message: '请上传文件!'
+          })
+        }
+      },
+      addSubfile () {
+        let _this = this
+        _this.newSubfileForm.SupplierId = parseInt(_this.serviceId)
+        _this.newSubfileForm.SupplierCertId = parseInt(_this.certId)
+
+        this.$refs['newSubfileForm'].validate((valid) => {
+          if (valid) {
+            _this.$axios.post('/annualaudit/addqualchange/' + _this.annualId, _this.newSubfileForm)
+              .then(res => {
+                if (res.data.code === 0) {
+                  _this.$message({
+                    type: 'success',
+                    message: res.data.message
+                  })
+                  this.newVisible = false
+                  this.getsubfile()
+                  this.$refs.newrefuploadattach.uploadFiles = []
+                } else {
+                  _this.$message({
+                    type: 'warning',
+                    message: res.data.message
+                  })
+                }
+              })
+              .catch(err => {
+                console.error(err)
+              })
+          }
+        })
+      },
+      newattachissuccess () {
+        if (this.$refs.newrefuploadattach.uploadFiles && this.$refs.newrefuploadattach.uploadFiles.length > 0) {
+          for (let i = 0; i < this.$refs.newrefuploadattach.uploadFiles.length; i++) {
+            if (this.$refs.newrefuploadattach.uploadFiles[i].status !== 'success') {
+              return false
+            }
+          }
+        }
+        return true
+      },
+      newgetattachissuccess () {
+        this.newSubfileForm.FileUrl = ''
+        this.newSubfileForm.FileName = ''
+        if (this.$refs.newrefuploadattach.uploadFiles && this.$refs.newrefuploadattach.uploadFiles.length > 0) {
+          for (let i = 0; i < this.$refs.newrefuploadattach.uploadFiles.length; i++) {
+            if (this.$refs.newrefuploadattach.uploadFiles[i].status === 'success') {
+              for (let j = 0; j < this.waituploads.length; j++) {
+                if (this.waituploads[j].uid === this.$refs.newrefuploadattach.uploadFiles[i].uid) {
+                  this.newSubfileForm.FileUrl +=
+                    `${this.waituploads[j].url}/${this.waituploads[j].fid}|${this.$refs.newrefuploadattach.uploadFiles[i].name}$`
+                  this.newSubfileForm.FileName += `${this.$refs.newrefuploadattach.uploadFiles[i].name}$`
+                }
+              }
+            }
+          }
+        }
+      },
+      delFile (row) {
+        let confirmmsg = '此操作将彻底删除该数据, 是否继续?'
+        this.$confirm(confirmmsg, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+          .then(() => {
+            annualapi.deleteAddfile(row.Id, this.$axios).then(res => {
+              if (res.data.code === 0) {
+                this.$message({
+                  type: 'success',
+                  message: res.data.message
+                })
+                this.getsubfile()
+              } else {
+                this.$message({
+                  type: 'warning',
+                  message: res.data.message
+                })
+              }
+            })
+          })
+          .catch(() => {})
+      },
+      showDialog () {
+        this.newVisible = true
+        this.newSubfileForm.NeedFileType = ''
+        this.newSubfileForm.EffectDate = ''
+        this.newSubfileForm.OtherRemark = ''
+      },
+
       // Tab
       nextTab () {
         let valid = true

+ 211 - 0
src/dashoo.cn/frontend_web/src/pages/oilsupplier/annualaudit/_opera/operation.vue

@@ -521,12 +521,16 @@
           <el-card class="box-card" style="margin-top: 10px;">
             <div slot="header" class="clearfix">
               <span style="font-weight: bold">企业资质</span>
+              <el-button style="float: right; padding: 3px 0" type="text" @click="showDialog" >添加</el-button>
             </div>
             <el-table :data="subfileList" border>
               <el-table-column label="操作" width="150" align="center" fixed v-if="Status <= 0">
                 <template slot-scope="scope">
                   <el-button type="primary" plain size="mini" title="文件变更" @click="openDialog(scope.row)">
                     变更</el-button>
+                  <el-button type="danger" plain size="mini" title="文件删除" @click="delFile(scope.row)"
+                             v-if="scope.row.FileType == 0 && scope.row.OldFileUrl == ''">
+                    删除</el-button>
                 </template>
               </el-table-column>
               <el-table-column prop="NeedFileType" label="文件分类" show-overflow-tooltip></el-table-column>
@@ -754,6 +758,47 @@
         <el-button type="primary" @click="makesure()">确 定</el-button>
       </div>
     </el-dialog>
+
+    <el-dialog title="新增文件" :visible.sync="newVisible" top="5vh">
+      <el-form ref="newSubfileForm" :model="newSubfileForm" label-width="100px" :rules="newrules">
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="资质名称" prop="NeedFileType">
+              <el-select v-model="newSubfileForm.NeedFileType" placeholder="请输文件类型" size="medium">
+                <el-option v-for="item in dynamicTableColumns" :key="item.prop" :label="item.label" :value="item.label">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="有效日期" prop="EffectDate">
+              <el-date-picker style="width: 100%" v-model="newSubfileForm.EffectDate" type="date" placeholder="请选择有效日期">
+              </el-date-picker>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="描述">
+              <el-input v-model="newSubfileForm.OtherRemark" type="textarea" :rows=3 placeholder="请输入备注信息"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="资质文件">
+              <el-upload multiple style="margin-top: 10px;" action="" ref="newrefuploadattach"
+                         :http-request="uploadrequest" class="attach-uploader" :before-upload="newbeforeAvatarUpload">
+                <i class="el-icon-plus attach-uploader-icon"></i>
+                <div slot="tip" class="el-upload__tip">大小为512KB-5MB
+                </div>
+              </el-upload>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer" style="margin-top:-30px;">
+        <el-button @click="newVisible = false">取 消</el-button>
+        <el-button type="primary" @click="makeNewSure()">确 定</el-button>
+      </div>
+    </el-dialog>
+
     <choose-auditor ref="chooseAuditor" @close="setAuditer" @hideChooseAuditer="chooseAuditorVisible=false"
       :visible="chooseAuditorVisible"></choose-auditor>
     <choose-auditor-fen ref="chooseAuditorFen" @close="setAuditerFen" @hideChooseAuditer="chooseAuditorVisibleFen=false"
@@ -786,6 +831,7 @@
   import axios from 'axios'
   import uploadajax from '@/assets/js//uploadajax.js'
   import fileapi from '@/api/oilsupplier/supplierfile'
+  import setapi from '@/api/oilsupplier/oilclassorgset'
 
   export default {
     computed: {
@@ -956,6 +1002,34 @@
         }
       }
       return {
+        newVisible: false,
+        newSubfileForm: {
+          Id: '',
+          SupplierId: '',
+          SupplierTypeCode: '03',
+          SupplierCertSubId: '',
+          CertSubName: '',
+          SupType: 2,
+          NeedFileType: '',
+          NeedFileCode: '',
+          FileType: 66,
+          FileExt: '',
+          FileName: '',
+          EffectDate: new Date(),
+          FileUrl: '',
+          OtherRemark: '',
+          Remark: '',
+          IsDelete: 0,
+          FileUrlList: []
+        },
+        dynamicTableColumns: [],
+        newrules: {
+          NeedFileType: [
+            {required: true, message: '资质名称不能为空', trigger: 'blur'}
+          ],
+          EffectDate:
+            [{ required: true, validator: effectDate, trigger: 'change' }]
+        },
         IsCompanyUser: 0,
         totalTab: 4,
         activeName: '0',
@@ -1429,8 +1503,145 @@
       }
       // this.orgtreeChange(this.majorDept)
       this.getsubfile()
+      this.initTableHeader()
     },
     methods: {
+      // 添加资质
+      initTableHeader () {
+        setapi.initTsTableHeader(this.$axios).then(res => {
+          this.dynamicTableColumns = res.data.items
+        })
+      },
+      newbeforeAvatarUpload (file) {
+        let isLt512K = file.size / 1024 < 512
+        if (isLt512K) {
+          this.$message.error('上传文件大小不能小于 512KB!')
+          return false
+        }
+        if (this.newSubfileForm.NeedFileType != this.yasuoname) {
+          if (file.type.indexOf('image') < 0) {
+            this.$message.error('上传图片!')
+            return false
+          }
+          let isLt50m = file.size / 1024 / 1024 / 5 < 1
+          if (!isLt50m) {
+            this.$message.error('上传文件大小不能超过 5MB!')
+            return false
+          }
+          return true
+        } else {
+          if (file.name.indexOf('.rar') < 0 && file.name.indexOf('.zip') < 0) {
+            this.$message.error('文件格式必须为rar或zip')
+            return false
+          }
+          return true
+        }
+      },
+      makeNewSure () {
+        if (this.$refs.newrefuploadattach.uploadFiles && this.$refs.newrefuploadattach.uploadFiles.length > 0) {
+          // 上传附件是否完成判断
+          if (!this.newattachissuccess()) {
+            this.$message.error('有附件未成功上传!不能保存数据')
+            return
+          }
+          this.newgetattachissuccess()
+          this.addSubfile()
+        } else {
+          this.$message({
+            type: 'warning',
+            message: '请上传文件!'
+          })
+        }
+      },
+      addSubfile () {
+        let _this = this
+        _this.newSubfileForm.SupplierId = parseInt(_this.serviceId)
+        _this.newSubfileForm.SupplierCertId = parseInt(_this.certId)
+
+        this.$refs['newSubfileForm'].validate((valid) => {
+          if (valid) {
+            _this.$axios.post('/annualaudit/addqualchange/' + _this.annualId, _this.newSubfileForm)
+              .then(res => {
+                if (res.data.code === 0) {
+                  _this.$message({
+                    type: 'success',
+                    message: res.data.message
+                  })
+                  this.newVisible = false
+                  this.getsubfile()
+                  this.$refs.newrefuploadattach.uploadFiles = []
+                } else {
+                  _this.$message({
+                    type: 'warning',
+                    message: res.data.message
+                  })
+                }
+              })
+              .catch(err => {
+                console.error(err)
+              })
+          }
+        })
+      },
+      newattachissuccess () {
+        if (this.$refs.newrefuploadattach.uploadFiles && this.$refs.newrefuploadattach.uploadFiles.length > 0) {
+          for (let i = 0; i < this.$refs.newrefuploadattach.uploadFiles.length; i++) {
+            if (this.$refs.newrefuploadattach.uploadFiles[i].status !== 'success') {
+              return false
+            }
+          }
+        }
+        return true
+      },
+      newgetattachissuccess () {
+        this.newSubfileForm.FileUrl = ''
+        this.newSubfileForm.FileName = ''
+        if (this.$refs.newrefuploadattach.uploadFiles && this.$refs.newrefuploadattach.uploadFiles.length > 0) {
+          for (let i = 0; i < this.$refs.newrefuploadattach.uploadFiles.length; i++) {
+            if (this.$refs.newrefuploadattach.uploadFiles[i].status === 'success') {
+              for (let j = 0; j < this.waituploads.length; j++) {
+                if (this.waituploads[j].uid === this.$refs.newrefuploadattach.uploadFiles[i].uid) {
+                  this.newSubfileForm.FileUrl +=
+                    `${this.waituploads[j].url}/${this.waituploads[j].fid}|${this.$refs.newrefuploadattach.uploadFiles[i].name}$`
+                  this.newSubfileForm.FileName += `${this.$refs.newrefuploadattach.uploadFiles[i].name}$`
+                }
+              }
+            }
+          }
+        }
+      },
+      delFile (row) {
+        let confirmmsg = '此操作将彻底删除该数据, 是否继续?'
+        this.$confirm(confirmmsg, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+          .then(() => {
+            annualapi.deleteAddfile(row.Id, this.$axios).then(res => {
+              if (res.data.code === 0) {
+                this.$message({
+                  type: 'success',
+                  message: res.data.message
+                })
+                this.getsubfile()
+              } else {
+                this.$message({
+                  type: 'warning',
+                  message: res.data.message
+                })
+              }
+            })
+          })
+          .catch(() => {})
+      },
+      showDialog () {
+        this.newVisible = true
+        this.newSubfileForm.NeedFileType = ''
+        this.newSubfileForm.EffectDate = ''
+        this.newSubfileForm.OtherRemark = ''
+      },
+
       // Tab
       nextTab () {
         // if (this.formData.AuditIndex > 0) {