wangting
2023-08-01 40c559dc4155783c39899a4bb44c26cb0efe40dd
Source/UBCS-WEB/src/components/template/Stage.vue
@@ -1,5 +1,5 @@
<template>
    <el-dialog title="模板阶段" width="90%" append-to-body="true" :visible.sync="dialogVisible">
    <div>
        <avue-crud ref="crud" :table-loading="loading" :data="data" :option="option" :page.sync="page"
            @on-load="getDataList" @size-change="handleSizePage" @current-change="handleCurrentPage"
            @row-click="handleRowClick">
@@ -8,7 +8,7 @@
                    @click="handleMaintenance(row, index)">维护</el-button>
            </template>
        </avue-crud>
        <el-dialog title="模板阶段" width="50%" append-to-body="true" :visible.sync="dialogNode">
        <el-dialog title="模板阶段" width="50%"  append-to-body="true" :visible.sync="dialogNode">
            <avue-crud ref="crud" :table-loading="loading" :data="stageData" :option="stageOption" @on-load="getStagelist"
                @row-click="handleRowStageClick">
                <template slot-scope="{type,size,row,index}" slot="menu">
@@ -17,9 +17,9 @@
                </template>
            </avue-crud>
        </el-dialog>
        <table-transfer :visible.sync="dialogTransfer" v-model="listVal" :dataList="tableData" :columns="columns"
            keyName="oid" @save="handleSave"></table-transfer>
    </el-dialog>
        <table-transfer v-if="flag" :visible.sync="dialogTransfer" v-model="attributeValue" :dataList="attributeData"
            :columns="columns" keyName="oid" @save="handleSave" @close="handelClose"></table-transfer>
    </div>
</template>
<script>
@@ -31,11 +31,6 @@
        TableTransfer
    },
    props: {
        // 是否打开
        visible: {
            typeof: Boolean,
            default: false
        },
        code: {
            typeof: String,
            required: true,
@@ -43,25 +38,11 @@
        }
    },
    watch: {
        visible(n) {
            this.dialogVisible = n;
        },
        dialogVisible(n) {
            this.$emit('update:visible', n)
        },
    },
    computed: {
        tableData() {
            return this.setTable()
        },
        listVal() {
            let data = this.setTable()
            let newdata = data.map(item => {
                return item.checked ? item.oid : undefined
            })
            console.log(newdata.filter(item => item))
            return newdata.filter(item => item)
      code: {
        handler(newval, oldval) {
          this.getDataList()
        }
      }
    },
    data() {
        const options = {
@@ -81,9 +62,9 @@
            editBtn: false,
        }
        return {
            list: [],
            listRight: [],
            dialogVisible: this.visible,
            attributeData: [],
            attributeValue: [],
            flag: false,
            dialogTransfer: false,
            dialogNode: false,
            visibleTable: false,
@@ -129,6 +110,7 @@
            },
            stageOption: {
                ...options,
              height:620,
                column: [
                    { label: '阶段编号', prop: 'taskId' },
                    { label: '阶段名称', prop: 'taskName' },
@@ -136,14 +118,11 @@
            },
        }
    },
    mounted() {
        this.getAttributeList()
    },
    methods: {
        setTable() {
            return this.list.map(item => {
                if (this.listRight.length !== 0) {
                    this.listRight.forEach(element => {
        setTable(data, list) {
            return data.map(item => {
                if (list.length !== 0) {
                    list.forEach(element => {
                        if (item.id === element.attrId) item.checked = true
                    });
                }
@@ -152,17 +131,19 @@
        },
        // 获取列表
        async getDataList() {
            this.loading = false
            const { pageSize, currentPage } = this.page
            let param = { size: pageSize, current: currentPage }
            const response = await getFlowpathList({ ...param, ...{ templateId: this.code } })
          this.loading = false
          if (this.code) {
            const {pageSize, currentPage} = this.page
            let param = {size: pageSize, current: currentPage}
            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
              console.log(response)
              this.loading = false
              const data = response.data.data
              this.data = data.records
              this.page.total = data.total
            } else this.loading = false
          }
        },
        // 获取阶段列表
        async getStagelist() {
@@ -178,12 +159,23 @@
        // 获取全部属性
        async getAttributeList() {
            const response = await attributeList({ 'conditionMap[classifyTemplateOid]': this.code })
            if (response.status === 200) {
                const data = response.data.data
                this.list = data.records.map(item => {
            const responseRight = await attributeListRight({ templateId: this.code, modelKey: this.modelKey, taskId: this.saveParam.taskId })
            if (response.status === 200 && responseRight.status === 200) {
                let datas = response.data.data.records
                let dataRight = responseRight.data.data
                datas = datas.map(item => {
                    const { oid, id, name, attributeGroup } = item
                    return { oid, id, name, attributeGroup, ...{ checked: false } }
                    item = { oid, id, name, attributeGroup, ...{ checked: false } }
                    if (dataRight.length !== 0) {
                        dataRight.forEach(element => { if (item.id === element.attrId) item.checked = true });
                    }
                    return item
                })
                console.log(datas)
                let dataValue = datas.map(item => item.checked ? item.oid : undefined)
                this.attributeValue = dataValue.filter(item => item)
                this.attributeData = datas
                this.flag = true
            }
        },
        // 获取已保存属性
@@ -202,20 +194,18 @@
        handleMaintenance(row) {
            console.log(row)
            this.dialogNode = true
            this.modelKey = row.modelKey
            this.saveParam.modelKey = row.modelKey
            this.getStagelist()
        },
        // 维护
        handleMaintenanceTransfer(row) {
            console.log(row)
            this.dialogTransfer = true
            this.saveParam.taskId = row.taskId
            this.saveParam.taskName = row.taskName
            this.getAttributeListRight()
        },
        handleSizePage(event) {
            this.page.pageSize = event
        },
        handleCurrentPage(event) {
            this.page.currentPage = event
            this.getAttributeList()
            this.$nextTick(() => {
                this.dialogTransfer = true
            })
        },
        handleRowClick(row) {
            console.log(row)
@@ -224,10 +214,12 @@
            this.dialogNode = true
        },
        handleRowStageClick(row) {
            this.dialogTransfer = true
            this.saveParam.taskId = row.taskId
            this.saveParam.taskName = row.taskName
            this.getAttributeListRight()
            this.getAttributeList()
            this.$nextTick(() => {
                this.dialogTransfer = true
            })
        },
        async handleSave(event) {
            console.log(event)
@@ -250,10 +242,14 @@
                    type: 'success',
                    message: '新增数据成功!'
                })
                this.flag = false
                // done()
                // this.getDataList()
            }
        },
        handelClose() {
            this.flag = false
        }
    }
}
</script>
</script>