zhangqi hai 3 meses
pai
achega
bb3b85c7ea

+ 21 - 31
src/HManagement/siteManage/securityConfig/modules/serviceImprovementRule.vue

@@ -105,6 +105,7 @@
         </el-table-column>
         <el-table-column :label="$t('操作')" width="100" align="center">
           <template slot-scope="scope">
+            <el-button v-if="scope.row.timestamp" type="text" size="mini" @click="saveRow(scope.row)">{{ $t('保存') }}</el-button>
             <el-button type="text" size="mini" @click="deleteRow(scope.row, scope.$index)">{{ $t('删除') }}</el-button>
           </template>
         </el-table-column>
@@ -112,7 +113,7 @@
 
       <div class="dialog-footer" style="margin-top: 20px; text-align: right;">
         <el-button size="small" @click="dialogVisible = false" class="normal-btn-width">{{$t('取 消')}}</el-button>
-        <el-button size="small" type="primary" class="normal-btn-width" @click="onSubmit">{{$t('确 定')}}</el-button>
+        <el-button size="small" type="primary" class="normal-btn-width" @click="dialogVisible = false">{{$t('确 定')}}</el-button>
       </div>
     </el-dialog>
   </div>
@@ -167,6 +168,10 @@ export default {
       this.queryData();
     },
     addRow() {
+      if (this.tableData.some(item => item.timestamp)) {
+        this.$message.warning(this.$t('请先保存当前新增行'));
+        return;
+      }
       this.tableData.push({
         timestamp: new Date().getTime(),
         name: '',
@@ -291,42 +296,27 @@ export default {
         }));
       }
     },
-    async onSubmit() {
-      // TODO: 调用接口保存配置
-      const updateRows = this.tableData.filter(item => item.timestamp);
-      if (updateRows.length === 0) {
-        this.$message.warning(this.$t('没有可保存的数据'));
+    async saveRow(row) {
+      if (!row.hrid) {
+        this.$message.warning(this.$t('请选择产品经理'));
         return;
       }
       
-      let successCount = 0;
-      let failCount = 0;
-
-      for (const item of updateRows) {
-        const res = await this.$api.requested({
-          "content": {
-            "hrid": item.hrid,
-            "userid": item.userid,
-            "models": item.productModel,
-          },
-          "id": 2026011709520902,
-        });
-        
-        if (res.code === 1) {
-          successCount++;
-        } else {
-          failCount++;
-        }
-      }
-
-      if (failCount === 0) {
+      const res = await this.$api.requested({
+        "content": {
+          "hrid": row.hrid,
+          "userid": row.userid,
+          "models": row.productModel,
+        },
+        "id": 2026011709520902,
+      });
+      
+      if (res.code === 1) {
         this.$message.success(this.$t('保存成功'));
-        this.dialogVisible = false;
+        this.queryData();
         this.$emit('queryRule');
       } else {
-        this.$message.warning(this.$t('保存完成,成功 {0} 条,失败 {1} 条', [successCount, failCount]));
-        // 失败时不关闭,或者刷新列表?这里选择刷新
-        this.$emit('queryRule');
+        this.$message.warning(res.msg || this.$t('保存失败'));
       }
     }
   }