李林
2024-02-26 8d817b3847f9a96850c1a28f7923940697df7235
src/components/view/data-reporting.vue
@@ -34,6 +34,9 @@
      height: calc(100% - 60px - 80px - 10px - 40px);
      padding: 20px;
   }
   .el-radio-group{
      width: 100%;
   }
</style>
<style>
   .data_reporting .data_reporting_dia .el-dialog__body {
@@ -55,7 +58,7 @@
         <el-row class="title">
            <el-col :span="12" style="padding-left: 20px;">数据上报</el-col>
            <el-col :span="12" style="text-align: right;padding-right: 8px;">
               <el-button size="medium" @click="openUpload()" v-if="inPower">
               <el-button size="medium" @click="chooseDia = true" v-if="inPower">
                  <i class="el-icon-upload2" style="color: #3A7BFA;"></i>
                  <span style="color: #3A7BFA;">导入</span>
               </el-button>
@@ -64,6 +67,7 @@
                  <span style="color: #3A7BFA;">导出</span>
               </el-button>
               <el-button size="medium" type="primary" @click="opeaAdd" v-if="addPower">新增</el-button>
               <el-button size="medium" type="danger" @click="delNowAll" v-if="delAllPower">一键删除</el-button>
            </el-col>
         </el-row>
      </div>
@@ -72,14 +76,16 @@
            <div class="search_label">系统日期:</div>
            <div class="search_input">
               <el-date-picker size="small" v-model="componentData.entity.createTime" type="date" placeholder="选择日期"
                  value-format="yyyy-MM-dd HH:mm:ss" clearable></el-date-picker>
                  value-format="yyyy-MM-dd HH:mm:ss" :clearable="false" :editable="false" @change="refreshTable"></el-date-picker>
            </div>
         </div>
         <div class="search_thing">
            <div class="search_label">登记人:</div>
            <div class="search_input">
               <el-input size="small" v-model="componentData.entity.registrant" clearable placeholder="登记人"
                  @keyup.enter.native="refreshTable()"></el-input>
               <el-select size="small" style="width: 100%;" placeholder="登记人" v-model="componentData.entity.registrant">
                  <el-option :value="null" label="全部"></el-option>
                  <el-option v-for="(a, ai) in userNames" :key="ai" :label="a" :value="a"></el-option>
               </el-select>
            </div>
         </div>
         <div class="search_thing">
@@ -101,7 +107,7 @@
            :delUrl="$api.dataReporting.delDataReporting" :componentData="componentData" :key="upIndex" @upRole="upRole" :downUrl="$api.dataReporting.downDataReportingFile"/>
      </div>
      <el-dialog title="上报修改" :visible.sync="upDia" width="700px" class="data_reporting_dia">
         <div class="body" v-if="upDia">
         <div class="body" v-if="upDia" style="max-height: 550px;overflow-y: auto;">
            <el-row style="line-height: 50px;">
               <el-col :span="4" style="text-align: right;padding-right: 8px;">系统日期</el-col>
               <el-col :span="7">
@@ -212,6 +218,12 @@
                  <el-input v-model="upData.remark" size="small"></el-input>
               </el-col>
            </el-row>
            <el-row style="line-height: 50px;">
               <el-col :span="4" style="text-align: right;padding-right: 8px;">微信号</el-col>
               <el-col :span="7">
                  <el-input v-model="upData.vxCard" size="small"></el-input>
               </el-col>
            </el-row>
         </div>
         <span slot="footer" class="dialog-footer" style="margin-right: 18px;">
            <el-button type="primary" @click="saveUpData" :loading="upLoad">确 定</el-button>
@@ -222,7 +234,7 @@
         <div style="margin: 0 auto;">
            <el-upload ref="upload" drag :action="javaApi + $api.dataReporting.inputCsv" :headers="token"
               :file-list="fileList" name="file" :auto-upload="false" accept=".csv" :limit="1" :on-change="beforeUpload"
               :on-success="onSuccess" :on-error="onError">
               :on-success="onSuccess" :on-error="onError" :data="{param: componentData.uploadStr}">
               <i class="el-icon-upload"></i>
               <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
            </el-upload>
@@ -230,6 +242,19 @@
         <span slot="footer" class="dialog-footer">
            <el-button @click="uploadDia = false">取 消</el-button>
            <el-button type="primary" @click="submitUpload()">上 传</el-button>
         </span>
      </el-dialog>
      <el-dialog title="请选择数据上报的微信号" :visible.sync="chooseDia" width="500px">
         <div class="body" v-if="chooseDia" style="max-height: 550px;overflow-y: auto;padding: 5px 0;">
            <el-radio-group v-model="vx">
               <el-col :span="8" v-for="(a, ai) in vxs" :key="ai" style="margin-bottom: 5px;">
                  <el-radio border size="small" :label="a.vx">{{a.vx}}</el-radio>
               </el-col>
            </el-radio-group>
         </div>
         <span slot="footer" class="dialog-footer">
            <el-button @click="chooseDia = false">取消</el-button>
            <el-button type="primary" @click="openUpload()">下一步</el-button>
         </span>
      </el-dialog>
   </div>
@@ -250,11 +275,11 @@
                  product: null,
                  orderBy: {
                     field: 'id',
                     order: 'desc'
                     order: 'asc'
                  }
               },
               isIndex: true,
               showSelect: true,
               showSelect: false,
               select: true,
               do: [{
                  id: 'update',
@@ -271,8 +296,14 @@
                  method: 'doDiy'
               }],
               tagField: {},
               selectField: {},
               requiredAdd:['name2','agent','channel','product','showNum','click','accountConsumption'],
               selectField: {
                  vxCard: {
                     select: []
                  }
               },
               requiredAdd:['name2','agent','channel','product','showNum','click','accountConsumption','vxCard'],
               countFleid: ['fansAdd'],
               uploadStr: ""
            },
            entityCopy: {},
            upIndex: 0,
@@ -287,7 +318,12 @@
            addPower: true,
            token: null,
            inPower: true,
            outPower: true
            outPower: true,
            delAllPower: true,
            userNames: [],
            vxs: [],
            chooseDia: false,
            vx: null
         }
      },
      created() {
@@ -312,14 +348,19 @@
         this.token = {
            'token': sessionStorage.getItem('token')
         }
         this.selectDataReportingForCreateUserNames()
         this.selectVxs()
      },
      methods: {
         refreshTable() {
            this.$refs['ValueTable'].selectList()
            this.selectDataReportingForCreateUserNames()
            this.selectVxs()
         },
         refresh() {
            this.componentData.entity = this.HaveJson(this.entityCopy)
            this.upIndex++
            this.selectDataReportingForCreateUserNames()
         },
         upRole(row) {
            this.upData = this.HaveJson(row)
@@ -358,6 +399,7 @@
            let add = false
            let inPower = false
            let outPower = false
            let delAllPower = false
            for (var i = 0; i < power.length; i++) {
               if (power[i].menuMethod == 'upDataReporting') {
                  up = true
@@ -374,6 +416,9 @@
               if (power[i].menuMethod == 'downDataReportingFile') {
                  outPower = true
               }
               if (power[i].menuMethod == 'deleteAllData') {
                  delAllPower = true
               }
            }
            if (!del) {
               this.componentData.do.splice(1, 1)
@@ -384,8 +429,14 @@
            this.addPower = add
            this.inPower = inPower
            this.outPower = outPower
            this.delAllPower = delAllPower
         },
         openUpload() {
            if(this.vx == null || this.vx == undefined) {
               this.$message.error('请选择数据上报的微信号')
               return
            }
            this.componentData.uploadStr = this.vx
            this.uploadDia = true
         },
         beforeUpload(file, fileList) {
@@ -402,11 +453,13 @@
            }
            this.uploading = true
            this.$refs.upload.submit();
            this.uploadDia = false
         },
         onSuccess(response, file, fileList) {
            this.$refs.upload.clearFiles()
            this.uploadDia = false
            this.uploading = false
            this.chooseDia = false
            if(response.code==201){
               this.$message.error(response.message)
               return
@@ -421,6 +474,52 @@
         },
         opeaAdd() {
            this.$refs.ValueTable.openAddDia(this.$api.dataReporting.addDataReporting);
         },
         delNowAll(){
            this.$confirm('是否删除 '+this.componentData.entity.createTime.split(' ')[0]+' 数据时间的全部数据?', "警告", {
               confirmButtonText: "确定",
               cancelButtonText: "取消",
               type: "error"
            }).then(() => {
               this.uploading = true
               this.$axios.post(this.$api.dataReporting.deleteAllData, {
                  date: this.componentData.entity.createTime.split(' ')[0]
               }).then(res => {
                  this.uploading = false
                  if (res.code === 201) {
                     return
                  }
                  this.$message.success('删除成功')
                  this.refreshTable()
               })
            }).catch(() => {})
         },
         selectDataReportingForCreateUserNames(){
            this.$axios.post(this.$api.dataReporting.selectDataReportingForCreateUserNames,{
               time: this.componentData.entity.createTime
            }).then(res => {
               this.userNames = res.data
            })
         },
         selectVxs(){
            this.$axios.get(this.$api.dataReporting.selectVxs,{
               params:{
                  time: this.componentData.entity.createTime
               }
            }).then(res => {
               if (res.code === 201) {
                  return
               }
               this.vxs = res.data
               var str = []
               res.data.forEach(a => {
                  str.push({
                     label: a.vx,
                     value: a.vx
                  })
               })
               this.componentData.selectField.vxCard.select = str
            })
         }
      }
   }