From 4f8513a18fd7cc6f0568cd2d9f94135ef861adc1 Mon Sep 17 00:00:00 2001 From: gaoshp <291585735@qq.com> Date: 星期日, 02 六月 2024 19:18:04 +0800 Subject: [PATCH] update --- src/views/dnc/setting/FTP.vue | 150 ++++++++++++++++++++++++++++++++++++++++++++++--- src/components/scForm/index.vue | 16 ++++- 2 files changed, 152 insertions(+), 14 deletions(-) diff --git a/src/components/scForm/index.vue b/src/components/scForm/index.vue index e3f1d76..5189a01 100644 --- a/src/components/scForm/index.vue +++ b/src/components/scForm/index.vue @@ -4,7 +4,7 @@ * @Author: sakuya * @Date: 2021骞�9鏈�22鏃�09:26:25 * @LastEditors: Sneed - * @LastEditTime: 2024-06-02 15:06:45 + * @LastEditTime: 2024-06-02 18:59:54 --> <template> @@ -85,8 +85,8 @@ <!-- radio --> <template v-else-if="item.component == 'radio'"> <el-radio-group v-model="form[item.name]"> - <el-radio v-for="_item in item.options.items" :key="_item.value" - :label="_item.value">{{ _item.label }}</el-radio> + <el-radio v-for="_item in item.options.items" :key="_item.value" :label="_item.value">{{ + _item.label }}</el-radio> </el-radio-group> </template> <!-- color --> @@ -109,6 +109,16 @@ <template v-else-if="item.component == 'editor'"> <sc-editor v-model="form[item.name]" placeholder="璇疯緭鍏�" :height="400"></sc-editor> </template> + <template v-else-if="item.component == 'el-tree-select'"> + <el-tree-select v-model="form[item.name]" :data="item.options.data" + :multiple="item.options.multiple" show-checkbox default-expand-all style="width: 240px" + :props="{ + label: 'title', + id: 'id', + ...item.options.props + }" node-key="id"> + </el-tree-select> + </template> <!-- noComponent --> <template v-else> <el-tag type="danger">[{{ item.component }}] Component not found</el-tag> diff --git a/src/views/dnc/setting/FTP.vue b/src/views/dnc/setting/FTP.vue index 8d196c8..1084c48 100644 --- a/src/views/dnc/setting/FTP.vue +++ b/src/views/dnc/setting/FTP.vue @@ -1,14 +1,24 @@ <!-- * @Date: 2024-05-26 22:26:35 * @LastEditors: Sneed - * @LastEditTime: 2024-06-02 15:16:59 + * @LastEditTime: 2024-06-02 19:17:45 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/setting/FTP.vue --> <template> <el-container> <el-header> <el-button type="primary" @click="addFtp">鍒涘缓FTP鐩綍</el-button> - <el-button type="primary" style="margin-right: auto;">鍏宠仈宸ヤ綅</el-button> + <el-tree-select v-model="params.workstationIds" clearable :data="treeData" multiple + :render-after-expand="false" style="width: 240px;margin-left: auto;" :props="{ + label: 'title', + + }" node-key="id"> + <template #prefix>宸ヤ綅鐩綍</template> + </el-tree-select> + <el-input v-model="params.name" style="width: 240px;margin-left: 8px;" placeholder="" clearable> + <template #prefix>鐩綍鍚嶇О</template> + </el-input> + <el-button style="margin-left: 8px;" @click="search" type="primary" icon="el-icon-search"></el-button> </el-header> <el-main> <el-row :gutter="20" style="width: 100%;"> @@ -20,7 +30,19 @@ <span class="">{{ scope.row.workstationDTOS.map(v => v.name).join(';') }}</span> </template> </el-table-column> - <el-table-column label="鎿嶄綔" prop="" width=""></el-table-column> + <el-table-column label="鎿嶄綔" prop="" width=""> + <template #default="scope"> + <el-button-group> + <el-button text type="primary" size="small" + @click="table_edit(scope.row, scope.$index)">鍏宠仈宸ヤ綅</el-button> + <el-popconfirm width="220" title="纭畾灏嗛�夋嫨鐨勬暟鎹垹闄�" @confirm="table_del(scope.row)"> + <template #reference> + <el-button text type="primary" size="small">鍒犻櫎</el-button> + </template> + </el-popconfirm> + </el-button-group> + </template> + </el-table-column> </el-table> </el-col> <el-col :span="12"> @@ -30,7 +52,7 @@ </el-row> </el-main> <scDialog v-model="showAdd"> - <scForm :config="config" :rules="rules"> + <scForm :config="config" :rules="rules" v-model="form" @submit="submit"> </scForm> </scDialog> @@ -44,6 +66,14 @@ return { tableData: [], showAdd: false, + treeData: [], + params: { + workstationIds: [], + name: '' + }, + form: { + + }, rules: { name: [ { required: true, message: '璇疯緭鍏ュ鍚�' } @@ -63,12 +93,12 @@ } }, { - component: 'input', + component: 'el-tree-select', label: '鍏宠仈宸ヤ綅', name: 'workstationIds', options: { - placeholder: '', - maxlength: 100, + multiple: false, + data: [] } } ] @@ -76,16 +106,114 @@ } }, created() { - this.getList() + this.search() + this.init() }, methods: { - getList() { - this.$HTTP.post(`/api/blade-dnc/ftp-director/ftp-workstation-list`, { name: '', workstationIds: [] }).then(res => { + init() { + this.$HTTP.post(`/api/blade-cps/group/groupWorkstation`, { groupCategory: 1, groupType: 'group_workstation' }).then(res => { + this.treeData = this.formatData(res.data) + + }) + }, + formatData(data, current, flag) { + let newData = [] + if (!current) { + newData = data.filter(item => item.parentId == 0).map(v => { + v.children = this.formatData(data, v, flag).sort((a, b) => { + return b.sort - a.sort + }) + flag && (v.disabled = !v.isWorkstation) + return v + }) + } else { + let res = data.filter(v => v.parentId == current.id) + res = res.map(item => { + item.children = this.formatData(data, item, flag).sort((a, b) => { + return b.sort - a.sort + }) + flag && (item.disabled = !item.isWorkstation) + return item + }) + return res + } + return newData + }, + search() { + this.$HTTP.post(`/api/blade-dnc/ftp-director/ftp-workstation-list`, this.params).then(res => { this.tableData = res.data }) }, addFtp() { - this.showAdd = true + this.form = {} + this.getAddList().then(res => { + this.config.formItems[1] = { + component: 'el-tree-select', + label: '鍏宠仈宸ヤ綅', + name: 'workstationIds', + options: { + multiple: true, + data: res, + props: { + disabled: 'disabled' + } + } + } + this.showAdd = true + }) + }, + getAddList(transferDirectorId) { + return this.$HTTP.post(`/api/blade-cps/group/groupFtpDirectory/ftp`, { groupCategory: 1, groupType: 'group_workstation', transferDirectorId }).then(res => { + this.addTreeData = this.formatData(res.data, null, 'disabled') + return this.addTreeData + }) + }, + submit(form) { + console.log(form) + if (form.id) { + return this.$HTTP.post(`/api/blade-dnc/ftp-director/update-director`, { + directorId: form.id, + directorName: form.name, + newWorkstationIds: form.workstationIds, + oldWorkstationIds: form.oldWorkstationIds + }).then(res => { + this.showAdd = false + this.search() + }) + } + this.$HTTP.post(`/api/blade-dnc/ftp-director/create-director`, form).then(res => { + this.showAdd = false + this.search() + }) + }, + table_edit(row) { + this.getAddList(row.id).then(res => { + this.config.formItems[1] = { + component: 'el-tree-select', + label: '鍏宠仈宸ヤ綅', + name: 'workstationIds', + options: { + multiple: true, + data: res, + props: { + disabled: 'disabled' + } + } + } + this.form = { + id: row.id, + name: row.name, + oldWorkstationIds: row?.workstationDTOS?.map(v => v.id) || [], + workstationIds: row?.workstationDTOS?.map(v => v.id) || [] + } + this.showAdd = true + }) + console.log(row) + }, + table_del(row) { + this.$HTTP.get(`/api/blade-dnc/ftp-director/del-director?id=${row.id}`).then(res => { + this.search() + }) } }, } -- Gitblit v1.9.3