ludc
2023-08-04 42c17fe468ceea7e5eed7fec520b9858bed02e85
Source/UBCS-WEB/src/components/template/FlowPath.vue
@@ -1,49 +1,36 @@
<template>
    <el-dialog title="模板流程" width="90%" append-to-body="true" :visible.sync="dialogVisible">
        <avue-crud ref="crud" :table-loading="loading" :data="data" v-model="form" :option="option" :page.sync="page"
            :search.sync="search" @on-load="getDataList" @row-save="handleSave" @row-del="handleDelete"
            @row-update="handleEdit" @refresh-change="handleRefresh" @size-change="handleSizePage"
            @current-change="handleCurrentPage" @selection-change="selectionChange" @row-click="handleRowClick">
            <template slot="menuLeft">
                <el-button icon="el-icon-delete" size="small" type="danger" @click="handleDeleteByIds">删 除
                </el-button>
            </template>
            <template slot="search" slot-scope="{row,size}">
                <el-input :placeholder="`请输入${selectValue === 'id' ? '系统编号' : '系统名称'}并按回车查询`" :size="size"
                    style="width:300px;margin-left: 10px;" v-model="search[selectValue]" clearable
                    @keyup.enter.native="handleEnter" @clear="handleClear"></el-input>
            </template>
            @current-change="handleCurrentPage" v-if="Formlist.length>0">
        </avue-crud>
    </el-dialog>
</template>
<script>
import { getFlowpathList, getStartList, flowpathSave } from '@/api/template/flowpath.js'
import { getFlowpathList, getStartList, flowpathSave, flowpathDelete } from '@/api/template/flowpath.js'
export default {
    name: 'FlowPath',
    props: {
        // 是否打开
        visible: {
            typeof: Boolean,
            default: false
        },
        code: {
            typeof: String,
            required: true,
            default: ""
        }
    },
    watch: {
        visible(n) {
            this.dialogVisible = n;
        },
        dialogVisible(n) {
            this.$emit('update:visible', n)
        },
      checkStatus: {
        type: Boolean,
        default: false
      },
      crudLCStatus: {
        type: String,
        default: 'Editing'
      },
      code: {
        typeof: String,
        required: true,
        default: ""
      },
      Formlist:{
        type:Array,
        default:[]
      }
    },
    data() {
        return {
            dialogVisible: this.visible,
            loading: false,
            page: {
                currentPage: 1,
@@ -56,66 +43,99 @@
            startData: [],
            form: {},
            option: {
                height: "auto",
                border: true,
                align: 'center',
                menuAlign: 'center',
                index: true,
                searchMenuSpan: 8,
                searchBtn: false,
                emptyBtn: false,
                columnBtn: false,
                defaultSort: {
                    prop: 'id,name,description,version',
                    order: 'descending'
              height: 340,
              border: true,
              align: 'center',
              menu:!this.checkStatus || this.crudLCStatus == 'Editing',
              menuAlign: 'center',
              index: true,
              searchMenuSpan: 8,
              searchBtn: false,
              refreshBtn:false,
              emptyBtn: false,
              columnBtn: false,
              editBtn:!this.checkStatus || this.crudLCStatus == 'Editing',
              delBtn:!this.checkStatus || this.crudLCStatus == 'Editing',
              addBtn: !this.checkStatus || this.crudLCStatus == 'Editing',
              defaultSort: {
                prop: 'id,name,description,version',
                order: 'descending'
              },
              column: [
                {
                  label: '模板key',
                  prop: 'modelKey',
                  width: 120,
                  sortable: true,
                  type: 'tree',
                  dicData: [],
                  props: {
                    label: "key",
                    value: "key"
                  },
                  rules: [{
                    required: true,
                    message: '模板key不能为空',
                    trigger: 'blur'
                  }],
                  nodeClick: (data) => {
                    console.log(data)
                    // 节点点击的时候会获取到数据
                    this.form.modelName = data.name
                  }
                }, {
                  label: '模板名称',
                  prop: 'modelName',
                  sortable: true,
                  width: 220,
                  addDisabled: true,
                  editDisabled: true,
                },
                selection: true,
                column: [
                    {
                        label: '模板key',
                        prop: 'modelKey',
                        sortable: true,
                        type: 'tree',
                        dicData: [],
                        props: {
                            label: "key",
                            value: "key"
                        },
                        rules: [{
                            required: true,
                            message: '模板key不能为空',
                            trigger: 'blur'
                        }],
                        nodeClick: (data) => {
                            console.log(data)
                            // 节点点击的时候会获取到数据
                            this.form.modeName = data.name
                        }
                    }, {
                        label: '模板名称',
                        prop: 'modelName',
                        sortable: true,
                        addDisabled: true,
                        editDisabled: true,
                    },
                    {
                        label: '流程模板用途',
                        prop: 'buttonTypeKey',
                        type: 'tree',
                        dicUrl: '/api/ubcs-flow/processTS/tt',
                        dicMethod: 'post',
                        props: {
                            value: "codee",
                            label: "namee",
                        },
                    },
                ]
            },
                {
                  label: '模板用途',
                  prop: 'buttonTypeKey',
                  type: 'tree',
                  width: 120,
                  dicUrl: '/api/ubcs-flow/processTS/tt',
                  dicMethod: 'post',
                  props: {
                    value: "codee",
                    label: "namee",
                  },
                },
                {
                  label: '模板描述',
                  prop: 'description',
                  type: 'textarea'
                },
              ]
            }
        }
    },
    created() {
        this.getStart()
    },
  watch: {
    code: {
      handler(newval, oldval) {
        this.getDataList()
      }
    },
    checkStatus: {
      handler(newval, oldval) {
        this.option.delBtn=!this.checkStatus || this.crudLCStatus == 'Editing';
        this.option.editBtn=!this.checkStatus || this.crudLCStatus == 'Editing';
        this.option.addBtn=!this.checkStatus || this.crudLCStatus == 'Editing';
      }
    },
    crudLCStatus: {
      handler(newval, oldval) {
        this.option.delBtn=!this.checkStatus || this.crudLCStatus == 'Editing';
        this.option.editBtn=!this.checkStatus || this.crudLCStatus == 'Editing';
        this.option.addBtn=!this.checkStatus || this.crudLCStatus == 'Editing';
      }
    }
  },
    methods: {
        async getStart() {
            const response = await getStartList()
@@ -132,24 +152,27 @@
        },
        // 获取列表
        async getDataList() {
            this.loading = false
            console.log(this.search)
          this.loading = false
          if(this.code){
            const { pageSize, currentPage } = this.page
            let param = { size: pageSize, current: currentPage }
            const response = await getFlowpathList({ ...param, ...this.search })
            const response = await getFlowpathList({ ...param, ...{ templateId: this.code } })
            if (response.status === 200) {
                console.log(response)
                this.loading = false
                const data = response.data.data
                this.data = data.records
                this.page.total = data.total
            }else this.loading = false
              this.loading = false
              const data = response.data.data
              this.data = data.records
              this.page.total = data.total
            } else this.loading = false
          }else {
            this.data=[]
          }
        },
        // 新增
        async handleSave(row, done, loading) {
            console.log(row)
            const response = await flowpathSave({...row,...{templateId:this.code}})
            if(response.status ===200){
            const response = await flowpathSave({ ...row, ...{ templateId: this.code } })
            if (response.status === 200) {
                loading()
                console.log(response)
                this.$message({
@@ -164,9 +187,9 @@
        // 编辑
        async handleEdit(row, index, done, loading) {
            console.log(row)
            const {modelName,modelKey,buttonTypeKey,id} = row
            let param = {modelName,modelKey,buttonTypeKey,id}
            const response = await flowpathSave({...param,...{templateId:this.code}})
            const { modelName, modelKey, buttonTypeKey, id ,description} = row
            let param = { modelName, modelKey, buttonTypeKey, id,description }
            const response = await flowpathSave({ ...param, ...{ templateId: this.code } })
            if (response.status === 200) {
                loading()
                this.$message({
@@ -180,20 +203,27 @@
        },
        // 删除单条
        handleDelete(row) {
            const { oid } = row
        },
        // 多条数据删除
        handleDeleteByIds() {
            console.log(row)
            const { id } = row
            this.deleteSysInfo({ id: id })
        },
        // 删除接口
        deleteSysInfo(param) {
            this.$confirm('是否确定删除选择的集成系统?', '提示', {
            this.$confirm('是否确定删除选择的模板流程?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(async () => {
                // 接口
                const response = await flowpathDelete(param)
                if (response.status === 200) {
                    console.log(response)
                    this.$message({
                        type: 'success',
                        message: '删除成功!'
                    });
                    this.getDataList()
                }
            })
        },
        // enter搜索
@@ -215,15 +245,6 @@
        handleCurrentPage(event) {
            this.page.currentPage = event
        },
        // 点击选择
        handleRowClick(row) {
            this.$refs.crud.toggleRowSelection(row, true)
        },
        // 多选
        selectionChange(list) {
            console.log(list)
        },
    }
}
</script>
</script>