Преглед изворни кода

前后:服务和供应商年度导出

dubch пре 4 година
родитељ
комит
1af03c9cf1

+ 53 - 71
src/dashoo.cn/backend/api/controllers/oilcontract/contractSumScore.go

@@ -832,8 +832,10 @@ func (this *OilContractSumScoreController) DocExport() {
 // @router /exportexcel [get]
 func (this *OilContractSumScoreController) ExcelExport() {
 	//获取分页信息
-	where := " 1=1 "
-	orderby := "score.Id"
+	page := this.GetPageInfoForm()
+	where  := " 1=1 "
+	having := " 1=1 "
+	orderby := "contract.SupplierId"
 	asc := false
 	Order := this.GetString("Order")
 	Prop := this.GetString("Prop")
@@ -843,84 +845,57 @@ func (this *OilContractSumScoreController) ExcelExport() {
 			asc = true
 		}
 	}
-	Id := this.GetString("Id")
-	SupplierId := this.GetString("SupplierId")
-	ContractClass := this.GetString("ContractClass")
 	SupplierName := this.GetString("SupplierName")
-	Year := this.GetString("Year")
-	Status := this.GetString("Status")
-	CreateOn := this.GetString("CreateOn")
-	CreateUserId := this.GetString("CreateUserId")
-	CreateBy := this.GetString("CreateBy")
-	ModifiedOn := this.GetString("ModifiedOn")
-	ModifiedUserId := this.GetString("ModifiedUserId")
-	ModifiedBy := this.GetString("ModifiedBy")
-	if Id != "" {
-		where = where + " and score.Id like '%" + Id + "%'"
-	}
-	if SupplierId != "" {
-		where = where + " and score.SupplierId like '%" + SupplierId + "%'"
-	}
+	//CreateOn     := this.GetString("CreateOn")
+	ContractClass := this.GetString("ContractClass", "01")
+	Evaluate := this.GetString("Evaluate", "")
+
 	if SupplierName != "" {
-		where = where + " and score.SupplierName like '%" + SupplierName + "%'"
+		where = where + " and contract.SupplierName like '%" + SupplierName + "%'"
 	}
 	if ContractClass != "" {
-		where = where + " and score.ContractClass like '%" + ContractClass + "%'"
-	}
-	if Year != "" {
-		where = where + " and score.Year like '%" + Year + "%'"
+		where = where + " and contract.ContractClass = '" + ContractClass + "'"
 	}
 
-	if Status != "" {
-		where = where + " and score.Status = '" + Status + "'"
-	}
-	//if CreateOn != "" {
-	//	where = where + " and CreateOn like '%" + CreateOn + "%'"
-	//}
 
-	if CreateUserId != "" {
-		where = where + " and score.CreateUserId like '%" + CreateUserId + "%'"
-	}
+	if Evaluate == "1" {  // 优秀
 
-	if CreateBy != "" {
-		where = where + " and score.CreateBy like '%" + CreateBy + "%'"
+	} else if Evaluate == "2" {  // 合格
+		having = "ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type = 1 then 1 else 0 end),2) <80"
+	} else if Evaluate == "3" {  // 不合格
+		having = "ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type = 1 then 1 else 0 end),2) <60"
 	}
+	// 今年的汇总
+	year := strconv.Itoa(time.Now().Year())
+	month := "01"
+	day := "01"
+	where = where + " and review.CreateOn>='" + year + "-" + month + "-" + day + "' "
 
-	if ModifiedOn != "" {
-		where = where + " and score.ModifiedOn like '%" + ModifiedOn + "%'"
-	}
+	//if CreateOn != "" {
+	//	dates := strings.Split(CreateOn, ",")
+	//	if len(dates) == 2 {
+	//		minDate := dates[0]
+	//		maxDate := dates[1]
+	//		where = where + " and review.CreateOn>='" + minDate + "' and review.CreateOn<='" + maxDate + "'"
+	//	}
+	//}
 
-	if ModifiedUserId != "" {
-		where = where + " and score.ModifiedUserId like '%" + ModifiedUserId + "%'"
-	}
+	// 审核通过的参与核算
+	where = where + " and review.Status='8' "
 
-	if ModifiedBy != "" {
-		where = where + " and score.ModifiedBy like '%" + ModifiedBy + "%'"
-	}
-	if CreateOn != "" {
-		dates := strings.Split(CreateOn, ",")
-		if len(dates) == 2 {
-			minDate := dates[0]
-			maxDate := dates[1]
-			where = where + " and score.CreateOn>='" + minDate + "' and score.CreateOn<='" + maxDate + "'"
-		}
-	}
-	where = where + " and items.Category = '0' "
+	svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
+	var list []contractSumScore.OilContractComputeSumScoreVo
+	svc.GetPagingComputeEntitiesWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, where,having)
 
-	//超级管理员和有查看所有数据权限的用户不加条件
-	svcPerm := permission.GetPermissionService(utils.DBE)
-	isauth := svcPerm.IsAuthorized(this.User.Id, "oil_contract.SumStore.AllRecord")
-	if !isauth {
-		// 权限过滤  自己创建的评价 ,同二级部门创建的评价 ,企管法规处能看
-		where = where + " and ( score.CreateUserId =  '" + this.User.Id + "' "
-		where = where + " or score.UnitId = '" + strconv.Itoa(this.User.UnitId) + "' "
-		where = where + " )"
+	var datainfo ErrorDataInfo
+	if len(list) == 0 {
+		datainfo.Code = -1
+		datainfo.Item = ""
+		datainfo.Message = "没有数据可导出"
+		this.Data["json"] = &datainfo
+		this.ServeJSON()
 	}
 
-	svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
-	var list []contractSumScore.OilContractSumScoreVo
-	svc.GetMyEntitiesWithOrderBytbl(orderby, asc, &list, where)
-
 	var Url string
 	var fileName string
 	fileName = ""
@@ -939,12 +914,19 @@ func (this *OilContractSumScoreController) ExcelExport() {
 	datamap["data"] = list
 
 	retDocUrl := svcActiviti.FillExcel(datamap, ContractClass, Url, fileName)
-	var datainfo ErrorDataInfo
-	datainfo.Code = 0
-	datainfo.Item = retDocUrl
-	datainfo.Message = "导出成功"
-	this.Data["json"] = &datainfo
-	this.ServeJSON()
+	if retDocUrl != "" {
+		datainfo.Code = 0
+		datainfo.Item = retDocUrl
+		datainfo.Message = "导出成功"
+		this.Data["json"] = &datainfo
+		this.ServeJSON()
+	} else {
+		datainfo.Code = -1
+		datainfo.Item = retDocUrl
+		datainfo.Message = "导出失败"
+		this.Data["json"] = &datainfo
+		this.ServeJSON()
+	}
 }
 
 // @Title 添加

BIN
src/dashoo.cn/doc/供应商年度评价表.xlsx


+ 50 - 31
src/dashoo.cn/frontend_web/src/pages/oilcontract/contract-goods-year/index.vue

@@ -11,10 +11,6 @@
         <span>
           <i class="icon icon-table2"></i> 供应商年度评价
         </span>
-        <span style="float: right;">
-          <!-- <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;">导入</el-button> -->
-          <!-- <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;" @click="exportExcel">导出</el-button> -->
-        </span>
         <el-form ref="form" :inline="true" style="float: right; margin-top: -10px">
           <el-form-item label="企业名称">
             <el-input size="mini" clearable v-model="searchForm.SupplierName" placeholder="请输入企业名称"></el-input>
@@ -40,6 +36,8 @@
                 <el-dropdown-item command="clear">查询重置</el-dropdown-item>
               </el-dropdown-menu>
             </el-dropdown>
+            <!-- <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;">导入</el-button> -->
+            <el-button type="primary" size="mini" style="margin-left:10px;" @click="exportExcel">导出</el-button>
           </el-form-item>
         </el-form>
       </div>
@@ -160,22 +158,20 @@
     computed: {
       ...mapGetters({
         authUser: 'authUser'
-      })
-    },
-    computed:{
+      }),
       evaluateFun:function(){
         return function(item){
           var index = Number(item)
           switch(index){
             case 1:
               return '优秀'
-            break;
+              break;
             case 2:
               return '合格'
-            break;
+              break;
             case 3:
               return '不合格'
-            break;
+              break;
             default:
               return '--'
           }
@@ -418,28 +414,51 @@
           }
         })
       },
-      exportExcel () {
-        /* generate workbook object from table */
-        let wb = XLSX.utils.table_to_book(
-          document.querySelector('#rebateSetTable')
-        )
-        /* get binary string as output */
-        let wbout = XLSX.write(wb, {
-          bookType: 'xlsx',
-          bookSST: true,
-          type: 'array'
-        })
-        try {
-          FileSaver.saveAs(
-            new Blob([wbout], {
-              type: 'application/octet-stream'
-            }),
-            'SupplierUsedName.xlsx'
-          )
-        } catch (e) {
-          if (typeof console !== 'undefined') console.log(e, wbout)
+      exportExcel() {
+        //分页及列表条件
+        let params = {
+          _currentPage: this.currentPage,
+          _size: this.size,
+          Order: this.Column.Order,
+          Prop: this.Column.Prop,
+          ContractClass: '01',
+        }
+        let myCreateOn = []
+        // 解析时间
+        if (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]))
         }
-        return wbout
+        //查询条件
+        Object.assign(params, this.searchForm)
+
+        api.docexportExcel(myCreateOn.join(','), params, this.$axios).then(res => {
+          if (res.data.code === 0) {
+            this.$message({
+              type: 'success',
+              message: res.data.message
+            })
+            let docurl = res.data.item
+            // 内网服务器专用
+            const myDomain = window.location.host
+            if (process.client && docurl.indexOf('upfile') === 0) {
+              const myDomain = window.location.host
+              location.href = 'http://' + myDomain + '/' + docurl
+            } else {
+              location.href = 'http://' + docurl
+            }
+          } else {
+            this.$message({
+              type: 'warning',
+              message: res.data.message
+            })
+          }
+        }).catch(err => {
+          console.error(err)
+        })
       },
       formatDateTime(date) {
         var y = date.getFullYear();

+ 49 - 28
src/dashoo.cn/frontend_web/src/pages/oilcontract/contract-service-year/index.vue

@@ -13,7 +13,6 @@
         </span>
         <span style="float: right;">
           <!-- <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;">导入</el-button> -->
-          <!-- <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;" @click="exportExcel">导出</el-button> -->
         </span>
         <el-form ref="form" :inline="true" style="float: right; margin-top: -10px">
           <el-form-item label="企业名称">
@@ -40,6 +39,7 @@
                 <el-dropdown-item command="clear">查询重置</el-dropdown-item>
               </el-dropdown-menu>
             </el-dropdown>
+             <el-button type="primary" size="mini" style="margin-left:10px;" @click="exportExcel">导出</el-button>
           </el-form-item>
         </el-form>
       </div>
@@ -151,22 +151,20 @@
     computed: {
       ...mapGetters({
         authUser: 'authUser'
-      })
-    },
-    computed:{
+      }),
       evaluateFun:function(){
         return function(item){
           var index = Number(item)
           switch(index){
             case 1:
               return '优秀'
-            break;
+              break;
             case 2:
               return '合格'
-            break;
+              break;
             case 3:
               return '不合格'
-            break;
+              break;
             default:
               return '--'
           }
@@ -351,28 +349,51 @@
           return val.substring(0, 10)
         }
       },
-      exportExcel () {
-        /* generate workbook object from table */
-        let wb = XLSX.utils.table_to_book(
-          document.querySelector('#rebateSetTable')
-        )
-        /* get binary string as output */
-        let wbout = XLSX.write(wb, {
-          bookType: 'xlsx',
-          bookSST: true,
-          type: 'array'
-        })
-        try {
-          FileSaver.saveAs(
-            new Blob([wbout], {
-              type: 'application/octet-stream'
-            }),
-            'SupplierUsedName.xlsx'
-          )
-        } catch (e) {
-          if (typeof console !== 'undefined') console.log(e, wbout)
+      exportExcel() {
+        //分页及列表条件
+        let params = {
+          _currentPage: this.currentPage,
+          _size: this.size,
+          Order: this.Column.Order,
+          Prop: this.Column.Prop,
+          ContractClass: '03',
+        }
+        let myCreateOn = []
+        // 解析时间
+        if (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]))
         }
-        return wbout
+        //查询条件
+        Object.assign(params, this.searchForm)
+
+        api.docexportExcel(myCreateOn.join(','), params, this.$axios).then(res => {
+          if (res.data.code === 0) {
+            this.$message({
+              type: 'success',
+              message: res.data.message
+            })
+            let docurl = res.data.item
+            // 内网服务器专用
+            const myDomain = window.location.host
+            if (process.client && docurl.indexOf('upfile') === 0) {
+              const myDomain = window.location.host
+              location.href = 'http://' + myDomain + '/' + docurl
+            } else {
+              location.href = 'http://' + docurl
+            }
+          } else {
+            this.$message({
+              type: 'warning',
+              message: res.data.message
+            })
+          }
+        }).catch(err => {
+          console.error(err)
+        })
       },
       formatDateTime(date) {
         var y = date.getFullYear();

+ 23 - 20
src/dashoo.cn/frontend_web/src/pages/oilcontract/contract-service/_opera/evaluate.vue

@@ -36,7 +36,7 @@
 
           <el-button type="primary" size="mini"
                      v-if="(Number(formData.Status)<=0&&saveButton)||(formData.Status=='4'&&auditBtn)"
-                     @click="onSeaveBigAdd">保存</el-button>
+                     @click="onSeaveBigAdd(1)">保存</el-button>
           <el-button @click="onBack" type="primary" size="mini" style="margin-left: 8px">返回</el-button>
         </span>
       </div>
@@ -228,7 +228,6 @@ export default {
       auditBtn: false,
       auditBtnBoolean: true,
       auditBtnBooleanZhuan: true,
-      auditstepcode: '',
 
       departmentBoolean: false,
       checkBUtton: false,
@@ -400,7 +399,7 @@ export default {
       this.$refs.submitpopup.dialogVisibleCom = true
     },
     //保存评价
-    onSeaveBigAdd() {
+    onSeaveBigAdd(val) {
       if (this.formData.Status != '4') {//普通二级用户评价evaluation_listType_one
         this.evaluation_list = this.$refs.evaluation_list_one.entityListData.entityList
         if (this.contractData.ContractClass == '02') {
@@ -420,7 +419,7 @@ export default {
             if (this.formData.Id == 0 || this.formData.Id == undefined || this.formData.Id == null) {
               this.addEvaluate()
             } else {
-              this.updateEvaluate()
+              this.updateEvaluate(val)
             }
           } else {
             this.$message.error('业绩评价填写的分数有误');
@@ -441,7 +440,7 @@ export default {
         // 获取第一列评价格式c
         this.$refs.evaluation_list_one.$refs.formEvaluation.validate((valid) => {
           if (valid) {
-            this.majorEvaluate()
+            this.majorEvaluate(val)
           } else {
             this.$message.error('业绩评价填写的分数有误');
           }
@@ -449,18 +448,20 @@ export default {
       }
     },
     //专业处室评价
-    majorEvaluate() {
-      var data = {
-        Items: this.evaluation_list,
+    majorEvaluate(val) {
+      let data = {
+        Items: this.evaluation_list
       }
       api.saveSecEvaluation(this.formData.Id, data, this.$axios).then(res => {
         console.log('新增', res)
         if (res.data.code == 0) {
-          this.$message({
-            type: 'success',
-            message: res.data.message
-          });
-          this.refreshPage();
+          if (val) {
+            this.$message({
+              type: 'success',
+              message: res.data.message
+            })
+          }
+          this.refreshPage()
         }
       }).catch(err => {
         console.error(err)
@@ -489,20 +490,22 @@ export default {
       });
     },
     //编辑评价
-    updateEvaluate() {
+    updateEvaluate(val) {
       var formData = {
         ContractId: this.contractData.Id,
-        Items: this.evaluation_list,
+        Items: this.evaluation_list
       }
       api.updateContractEvaluate(this.formData.Id, formData, this.$axios).then(res => {
         console.log('编辑', res)
         if (res.data.code == 0) {
           // this.formData.Id = res.data.item
-          this.$message({
-            type: 'success',
-            message: res.data.message
-          });
-          this.refreshPage();
+          if (val) {
+            this.$message({
+              type: 'success',
+              message: res.data.message
+            })
+          }
+          this.refreshPage()
         }
       }).catch(err => {
         console.error(err)