Przeglądaj źródła

后:现场考察报告大改

MAC 5 lat temu
rodzic
commit
7836f1d683

+ 77 - 3
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -2182,6 +2182,79 @@ func (this *OilSupplierController) EditSubfile() {
 	}
 }
 
+// @Title 更新文件上传
+// @Description 更新文件上传copy
+// @Param	id	path	string	true
+// @Success	200	{object}
+// @router /editsubfilecopy/:id [put]
+func (this *OilSupplierController) EditSubfileCopy() {
+	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 supplierscenefile.OilSupplierSceneFile
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
+	model.FileUrl = strings.Trim(model.FileUrl, "$")
+	model.FileName = strings.Trim(model.FileName, "$")
+	model.CreateOn = time.Now()
+	model.CreateBy = this.User.Realname
+	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+
+	_, err := svc.InsertEntity(&model)
+
+	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} ErrorInfo
+// @Failure 403 :id 为空
+// @router /editsubfiledelete/:Id [delete]
+func (this *OilSupplierController) EditSubfileDelete() {
+	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 supplierscenefile.OilSupplierSceneFile
+	var model1 supplierscenefile.OilSupplierSceneFile
+	svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
+	opdesc := "删除-" + Id
+	err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierSceneFileName, BaseOperationLogName, Id, &model, &model1, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "考察报告删除")
+	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 get 导入excel
 // @Description get SampleType by token
 // @Success 200 {object} sampletype.SampleType
@@ -2273,12 +2346,13 @@ func (this *OilSupplierController) OperationCell(svc *supplier.OilSupplierServic
 // @router /getscenefilelist [get]
 func (this *OilSupplierController) GetSceneFileList() {
 	supplierId := this.GetString("SupplierId")
-
-	var model supplierscenefile.OilSupplierSceneFile
+	page := this.GetPageInfoForm()
+	orderby := "Id"
+	var model []supplierscenefile.OilSupplierSceneFile
 
 	svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
 	where := "SupplierId=" + supplierId
-	svc.GetEntity(&model, where)
+	svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, true, &model, where)
 
 	var errinfo ErrorDataInfo
 	errinfo.Item = model

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

@@ -92,6 +92,12 @@ export default {
       method: 'delete'
     })
   },
+  deleteFileEntity(entityId, myAxios) {
+    return myAxios({
+      url: '/supplier/editsubfiledelete/'+entityId,
+      method: 'delete'
+    })
+  },
   deleteAllEntity (entityId, supplierTypeCode, myAxios) {
     return myAxios({
       url: '/supplier/deleteall/' + entityId + '/' + supplierTypeCode,

+ 117 - 34
src/dashoo.cn/frontend_web/src/components/oilsupplier/goodsinfo.vue

@@ -693,7 +693,7 @@
              style="margin-top: 10px;">
       <div slot="header"
            class="clearfix">
-        <span style="padding:3px 20px">所代理制造商名称(先保存基本信息后再添加)</span>
+        <span style="padding:3px 20px">所代理制造商名称 </span>
         <el-button style="float: right; padding: 3px 10px"
                    type="text"
                    @click="manufacturerdialog"
@@ -718,26 +718,40 @@
       <el-table :data="scenefileurllist" border size="mini" empty-text="暂无数据" style="margin-top: 30px;">
         <el-table-column prop="FileUrlList" label="报告" show-overflow-tooltip>
           <template slot-scope="scope">
-            <viewer :images="scenefileurllist">
-              <el-col :span="6"  v-for="(tmpUrl,index) in scenefileurllist" v-if="index<1" :key="index" style="vertical-align: middle;	text-align: center;">
-                <el-link :href="'http://'+fileurlcut(scenefile.FileUrl, scope.$index)" target="_blank" type="primary"
-                         v-if="imgFormat(scenefile.FileUrl, index)" >
-                  {{scenefile.FileName.split('$')[scope.$index]}}</el-link>
+<!--            <viewer :images="scenefileurllist">-->
+<!--              <el-col :span="6"  v-for="(tmpUrl,index) in scenefileurllist" v-if="index<1" :key="index" style="vertical-align: middle;	text-align: center;">-->
+<!--                <el-link :href="'http://'+fileurlcut(scenefile.FileUrl, scope.$index)" target="_blank" type="primary"-->
+<!--                         v-if="imgFormat(scenefile.FileUrl, index)" >-->
+<!--                  {{scenefile.FileName.split('$')[scope.$index]}}</el-link>-->
+<!--                <img-->
+<!--                  v-else-->
+<!--                  class="photoStyle" alt=""-->
+<!--                  :src="'http://'+fileurlcut(scenefile.FileUrl, scope.$index)"-->
+<!--                  :key="index">-->
+<!--              </el-col>-->
+<!--            </viewer>-->
+            <viewer>
+              <div style="vertical-align: middle;	text-align: center;">
+                <el-link :href="'http://'+fileurlcut(scope.row.FileUrl)" target="_blank" type="primary"
+                         v-if="imgFormat(scope.row.FileUrl)" >
+                  {{scope.row.FileUrl}}</el-link>
                 <img
                   v-else
                   class="photoStyle" alt=""
-                  :src="'http://'+fileurlcut(scenefile.FileUrl, scope.$index)"
-                  :key="index">
-              </el-col>
+                  :src="'http://'+fileurlcut(scope.row.FileUrl)">
+              </div>
             </viewer>
           </template>
         </el-table-column>
-        <el-table-column prop="FileUrlList" label="描述" show-overflow-tooltip>{{scenefile.Remark}}
+        <el-table-column prop="FileUrlList" label="描述" show-overflow-tooltip>
+          <template slot-scope="scope">
+            {{scope.row.Remark}}
+          </template>
         </el-table-column>
         <el-table-column label="操作" width="150" align="center" fixed>
           <template slot-scope="scope">
             <el-button type="primary" plain size="mini" title="删除" style="margin-left:3px" :disabled="checkStatus.includes(formData.Status)"
-                       v-if="scenefile.FileName != ''" @click="deletedata(scenefile.FileName.split('$')[scope.$index], scenefile.FileUrl.split('$')[scope.$index])">删除</el-button>
+                       v-if="scope.row.FileName != ''" @click="deletedata(scope.row.Id)">删除</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -750,7 +764,7 @@
         <el-row>
           <el-col :span="12">
             <el-form-item label="现场考察报告">
-              <el-upload multiple style="margin-top: 10px;" action="" ref="refuploadattach"
+              <el-upload :limit="1" style="margin-top: 10px;" action="" ref="refuploadattach"
                          :http-request="uploadrequest" class="attach-uploader" :before-upload="beforeAvatarUpload">
                 <i class="el-icon-plus attach-uploader-icon"></i>
               </el-upload>
@@ -774,6 +788,7 @@
 
 <script>
 import axios from 'axios'
+import api from '@/api/oilsupplier/supplier'
 import uploadajax from '../../assets/js/uploadajax.js'
 import ManufacturerList from '@/components/oilsupplier/manufacturerlist'
 
@@ -998,6 +1013,7 @@ export default {
         FileName: '',
         Remark: ''
       },
+      isscenefile: false,
       countryprops: {
         value: 'adcode',
         label: 'name',
@@ -1190,14 +1206,35 @@ export default {
     getCurrentManufactureCount2 () {
       return this.$refs['manufacturerList'].getCurrentManufactureCount3()
     },
-    deletedata (FileName, FileUrl) {
+    deletedata (id) {
       let _this = this
       _this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
-        this.editSubfile(FileName, FileUrl)
+        // this.editSubfile(FileName, FileUrl)
+        api.deleteFileEntity(id, _this.$axios)
+          .then(res => {
+            if (res.data.code === 0) {
+              _this.$message({
+                type: 'success',
+                message: res.data.message
+              })
+              this.visible = false
+              this.$emit('initFDatas')
+              this.getSupplierSceneFile()
+              this.$refs.refuploadattach.uploadFiles = []
+            } else {
+              _this.$message({
+                type: 'warning',
+                message: res.data.message
+              })
+            }
+          })
+          .catch(err => {
+            console.error(err)
+          })
       }).catch(() => {
         this.$message({
           type: 'info',
@@ -1238,24 +1275,37 @@ export default {
     manufacturerdialog () {
       this.$refs['manufacturerList'].showDialog()
     },
-    imgFormat (val, index) {
-      if (val != null && val != undefined && val != '') {
-        let fileurlall = val.split('$')[index]
-        let fileurl = fileurlall.split('|')
-        if (fileurl[1] != null && fileurl[1] != '' && fileurl[1] != undefined) {
-          let Format = fileurl[1].split('.')
-          if (Format[1] != null && Format[1] !='' && Format[1] != undefined) {
-            let pictureFormat = Format[1]
-            if (pictureFormat == 'jpg' || pictureFormat == 'bmp' || pictureFormat == 'png' || pictureFormat == 'gif' || pictureFormat == 'jpeg') {
-              return false
-            }
+    // imgFormat (val, index) {
+    //   if (val != null && val != undefined && val != '') {
+    //     let fileurlall = val.split('$')[index]
+    //     let fileurl = fileurlall.split('|')
+    //     if (fileurl[1] != null && fileurl[1] != '' && fileurl[1] != undefined) {
+    //       let Format = fileurl[1].split('.')
+    //       if (Format[1] != null && Format[1] !='' && Format[1] != undefined) {
+    //         let pictureFormat = Format[1]
+    //         if (pictureFormat == 'jpg' || pictureFormat == 'bmp' || pictureFormat == 'png' || pictureFormat == 'gif' || pictureFormat == 'jpeg') {
+    //           return false
+    //         }
+    //       }
+    //     }
+    //     return true
+    //   }
+    // },
+    imgFormat (fileurl) {
+      if (fileurl != null && fileurl != undefined && fileurl != '') {
+        let Format = fileurl.split('.')
+        if (Format[1] != null && Format[1] != '' && Format[1] != undefined) {
+          let pictureFormat = Format[1]
+          if (pictureFormat == 'jpg' || pictureFormat == 'bmp' || pictureFormat == 'png' || pictureFormat == 'gif' || pictureFormat == 'jpeg') {
+            return true
           }
         }
-        return true
       }
+      return false
     },
     fileurlcut (val, index) {
-      let fileurlall = val.split('$')[index]
+      // let fileurlall = val.split('$')[index]
+      let fileurlall = val
       let fileurl = fileurlall.split('|')
       let retUrl = fileurl[0]
       // 内网服务器专用
@@ -1373,6 +1423,31 @@ export default {
           console.error(err)
         })
     },
+    editSubfileCopy () {
+      let _this = this
+      _this.SubfileForm.SupplierId = parseInt(_this.formData.Id)
+      console.log(_this.SubfileForm, '2222')
+      _this.$axios.put('/supplier/editsubfilecopy/' + this.SubfileForm.SupplierId, _this.SubfileForm)
+        .then(res => {
+          if (res.data.code === 0) {
+            _this.$message({
+              type: 'success',
+              message: res.data.message
+            })
+            this.visible = false
+            this.$emit('initFDatas')
+            this.$refs.refuploadattach.uploadFiles = []
+          } else {
+            _this.$message({
+              type: 'warning',
+              message: res.data.message
+            })
+          }
+        })
+        .catch(err => {
+          console.error(err)
+        })
+    },
     getSupplierSceneFile () {
       if (this.formData.Id !== '') {
         let params = {
@@ -1381,13 +1456,20 @@ export default {
         this.isInvestigate = true
         this.$axios.get('/supplier/getscenefilelist', {params}).then(res => {
           // TODO 文件已经仅只上传一张, 还需展示描述
-          this.scenefile = res.data.item
-          console.log('345', this.scenefile)
-          if (this.scenefile && this.scenefile.FileUrl && this.scenefile != null) {
-            this.scenefileurllist = this.scenefile.FileUrl.split('$')
-            // this.scenefileurllist.push(this.scenefile.Remark)
-            console.log('222', this.scenefileurllist)
+          this.scenefileurllist = res.data.item
+          // this.scenefileurl = res.data.item
+          if (this.scenefileurllist && this.scenefileurllist.length > 0) {
+            this.isscenefile = true
+          } else {
+            this.isscenefile = false
           }
+          console.log('345', this.scenefileurllist)
+          console.log('345', this.isscenefile)
+          // if (this.scenefile && this.scenefile.FileUrl && this.scenefile != null) {
+            // this.scenefileurllist = this.scenefile.FileUrl.split('$')
+            // this.scenefileurllist.push(this.scenefile.Remark)
+          //   console.log('222', this.scenefileurllist)
+          // }
         })
       }
     },
@@ -1399,7 +1481,8 @@ export default {
           return
         }
         this.getattachissuccess()
-        this.editSubfile('', '')
+        // this.editSubfile('', '')
+        this.editSubfileCopy()
         return false
       } else {
         this.$message({

+ 3 - 2
src/dashoo.cn/frontend_web/src/pages/oilsupplier/supplier/_opera/goodsedit.vue

@@ -1418,7 +1418,7 @@ export default {
       if (this.activeName === '0' &&
         this.formDataCert.InStyle != '2' && this.formDataCert.InStyle != '3') {
         // 准入方式,除一级二级外其他需要考察报告
-        if (this.$refs['GoodsInfo'].scenefile.FileUrl.length <= 0) {
+        if (!this.$refs['GoodsInfo'].isscenefile) {
           this.$notify({
             title: '提示',
             message: '请上传现场考察报告!',
@@ -1839,8 +1839,9 @@ export default {
     },
     commitAudit () {
       if (this.formDataCert.InStyle != '2' && this.formDataCert.InStyle != '3') {
+        console.log(this.$refs['GoodsInfo'].isscenefile, 'DA11')
         // 准入方式,除一级二级外其他需要考察报告
-        if (this.$refs['GoodsInfo'].scenefile.FileUrl.length <= 0) {
+        if (!this.$refs['GoodsInfo'].isscenefile) {
           this.$notify({
             title: '提示',
             message: '请上传现场考察报告!',