yuwandanmian 2 роки тому
батько
коміт
ae7ed5e015

+ 14 - 4
src/views/allcase/caseIndex.vue

@@ -39,9 +39,6 @@
             <el-form-item>
               <el-button type="primary" @click="onSearch">查询</el-button>
             </el-form-item>
-            <el-form-item v-if="greenColorMenus.includes(ruleId) && tableData.length" style="float: right;">
-              <el-button @click="onChangeValue">编辑</el-button>
-            </el-form-item>
             <el-form-item style="float: right;">
               <el-button v-if="$route.query.type === 'children'" @click="onBack">返回</el-button>
             </el-form-item>
@@ -61,6 +58,10 @@
               </template>
             </el-table-column>
             <el-table-column prop="" label="操作" width="120">
+              <template slot="header" slot-scope="scope">
+                  <span>操作</span>
+                <i class="el-icon-edit table_edit" v-if="scope._self.judgeEdit" @click="onChangeValue"></i>
+              </template>
               <template slot-scope="scope">
                 <!-- 全年不可修改 -->
                 <!-- 非人工录入不可修改 -->
@@ -556,7 +557,8 @@ export default {
       return this.$route.query.type === 'children' ? this.cMenus : this.menus
     },
     judgeEdit() {
-      return this.greenColorMenus.includes(this.ruleId)
+      console.log(this.greenColorMenus.includes(this.ruleId))
+      return this.greenColorMenus.includes(this.ruleId) && !!this.tableData.length
     }
   },
   watch: {
@@ -566,6 +568,7 @@ export default {
   },
   methods: {
     onChangeValue(row) {
+      console.log(row, 9999)
       if (row.time) {
         // 单个修改
         const { time } = row
@@ -668,6 +671,13 @@ export default {
 </script>
 
 <style lang="scss" scoped>
+.table_edit {
+  margin-left: 10px;
+  cursor: pointer;
+  &:hover {
+    opacity: 0.6;
+  }
+}
 .link {
   font-weight: 600;
   color: #409eff;

+ 7 - 15
src/views/allcase/components/ChangeCaseIndexValueDialog.vue

@@ -3,9 +3,14 @@
     <el-dialog
       title="修改"
       :visible.sync="data.bSwitch"
-      width="400px">
+      width="400px"
+      :top="data.rows.length > 1 ? '3vh' : '15vh'">
       <span style="line-height: 40px;">请输入指标数据</span>
-      <el-input-number v-model="num" :min="0" label="请输入" :controls="false" style="width: 100%;"></el-input-number>
+      <el-form ref="form" label-width="80px">
+        <el-form-item v-for="(item, index) of data.rows" :key="index" :label="`${item.year}-${item.month}`">
+          <el-input-number v-model="item.num" :min="0" label="请输入" :controls="false" style="width: 100%;"></el-input-number>
+        </el-form-item>
+      </el-form>
       <span slot="footer" class="dialog-footer">
         <el-button @click="data.bSwitch = false">取 消</el-button>
         <el-button type="primary" @click="onSubmit">确 定</el-button>
@@ -27,24 +32,11 @@
         }
       }
     },
-    data() {
-      return {
-        num: 0
-      }
-    },
-    created() {
-      if (this.data.rows.length === 1) {
-      this.num = this.data.rows[0].num
-      }
-    },
     methods: {
       onSubmit() {
         const params = {
           save_data: JSON.parse(JSON.stringify(this.data.rows))
         }
-        params.save_data.map(item => {
-          item.num = this.num
-        })
         this.$axios2.post('/add_zb', params).then(res => {
           this.$message.success('修改成功')
           this.data.bSwitch = false