zhangxp
2023-06-14 f2c0dc24a5142ddc08912456d55c80351cf4d9b6
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">
@@ -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,7 @@
        }
    },
    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)
        }
    },
    data() {
        const options = {
@@ -81,9 +58,9 @@
            editBtn: false,
        }
        return {
            list: [],
            listRight: [],
            dialogVisible: this.visible,
            attributeData: [],
            attributeValue: [],
            flag: false,
            dialogTransfer: false,
            dialogNode: false,
            visibleTable: false,
@@ -136,14 +113,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
                    });
                }
@@ -178,12 +152,22 @@
        // 获取全部属性
        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
                    }
                })
                let dataValue = datas.map(item => item.checked ? item.oid : undefined)
                this.attributeValue = dataValue.filter(item => item)
                this.attributeData = datas
                this.flag = true
            }
        },
        // 获取已保存属性
@@ -205,17 +189,12 @@
            this.saveParam.modelKey = row.modelKey
        },
        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 +203,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,9 +231,13 @@
                    type: 'success',
                    message: '新增数据成功!'
                })
                this.flag = false
                // done()
                // this.getDataList()
            }
        },
        handelClose() {
            this.flag = false
        }
    }
}