Browse Source

新增图纸状态切换功能,支持启用/停用操作

chrislee 2 weeks ago
parent
commit
10d3896b7d
2 changed files with 76 additions and 3 deletions
  1. 49 2
      src/views/modules/tech/draw-management.vue
  2. 27 1
      src/views/modules/tech/project-tech.vue

+ 49 - 2
src/views/modules/tech/draw-management.vue

@@ -74,9 +74,21 @@
         <el-table-column prop="notes" header-align="center" align="center" min-width="180" :show-overflow-tooltip="true"
           label="备注">
         </el-table-column>
-        <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
+        <el-table-column prop="state" header-align="center" align="center" width="100" label="状态">
           <template slot-scope="scope">
-            <el-button type="text" size="small" @click="detailHandle(scope.row.drawingId)">删除</el-button>
+            <el-tag :type="Number(scope.row.state) === 1 ? 'success' : 'danger'" disable-transitions>
+              {{ Number(scope.row.state) === 1 ? '启用' : '停用' }}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column fixed="right" header-align="center" align="center" width="100" label="操作">
+          <template slot-scope="scope">
+            <!-- 查看 -->
+            <el-button type="text" size="small" @click="detailHandle(scope.row.drawingId)">查看</el-button>
+            <!-- 启用/停用 -->
+            <el-button v-if="isAuth('pro:drawing:update')" type="text" size="small" @click="toggleState(scope.row)">
+              {{ Number(scope.row.state) === 1 ? '停用' : '启用' }}
+            </el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -102,6 +114,7 @@ import ProductComponent from '@/views/modules/common/product-component'
 import PreviewComponent from '@/views/modules/common/preview-component.vue'
 import ImagePreview from '@/views/modules/common/image-preview.vue'
 import ImageViewerMixin from '@/views/modules/common/mixins/image-viewer-mixin'
+import { isAuth } from '@/utils'
 export default {
   name: 'draw-management',
   mixins: [ImageViewerMixin],
@@ -216,6 +229,40 @@ export default {
         })
       }).catch(() => { })
     },
+    // 启用/停用
+    toggleState(row) {
+      if (!row || !row.drawingId) return
+      const current = Number(row.state)
+      const targetState = current === 1 ? 2 : 1
+      const actionText = targetState === 1 ? '启用' : '停用'
+      this.$confirm(`确定${actionText}该图纸?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.$http({
+          url: this.$http.adornUrl('/biz-service/drawing/update'),
+          method: 'POST',
+          data: {
+            drawingId: row.drawingId,
+            state: targetState
+          }
+        }).then(({ data }) => {
+          if (data && data.code === '200') {
+            this.$message({
+              message: '操作成功',
+              type: 'success',
+              duration: 1500,
+              onClose: () => {
+                this.getDataList()
+              }
+            })
+          } else {
+            this.$message.error(data && data.msg ? data.msg : '操作失败')
+          }
+        })
+      }).catch(() => { })
+    },
     // 预览
     previewFile(fileName, url) {
       this.previewVisible = true

+ 27 - 1
src/views/modules/tech/project-tech.vue

@@ -35,13 +35,15 @@
         <el-table-column prop="state" header-align="center" align="center" min-width="60"
           :show-tooltip-when-overflow="true" :formatter="formatState" label="状态">
         </el-table-column>
-        <el-table-column fixed="right" header-align="center" align="center" width="130" label="操作">
+        <el-table-column fixed="right" header-align="center" align="center" width="170" label="操作">
           <template slot-scope="scope">
             <el-button type="text" size="small" @click="submitHandle(scope.row, true)">查看</el-button>
             <el-button v-if="scope.row.state == 1" type="text" size="small"
               @click="assignHandle(scope.row)">分派</el-button>
             <el-button v-if="scope.row.state == 1" type="text" size="small"
               @click="submitHandle(scope.row, false)">处理</el-button>
+            <el-button v-if="isAuth('fin:customer:info') && scope.row.state == 1" type="text" size="small"
+              @click="completeHandle(scope.row)">完成</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -195,6 +197,30 @@ export default {
       this.$nextTick(() => {
         this.$refs.noticeChange.init()
       })
+    },
+    // 完成
+    completeHandle(item) {
+      const id = item && item.technologyId
+      if (!id) {
+        this.$message.error('未获取到技术单ID,无法完成')
+        return
+      }
+      this.$http({
+        url: this.$http.adornUrl(`/biz-service/projTechnology/completed`),
+        method: 'post',
+        data: this.$http.adornData({ id })
+      }).then(({ data }) => {
+        if (data && data.code === '200') {
+          this.$message({
+            message: '操作成功',
+            type: 'success',
+            duration: 1500
+          })
+          this.getDataList()
+        } else {
+          this.$message.error(data && data.msg ? data.msg : '操作失败')
+        }
+      })
     }
   }
 }