| | |
| | | <!-- |
| | | * @Date: 2024-04-09 22:18:47 |
| | | * @LastEditors: Sneed |
| | | * @LastEditTime: 2024-04-13 21:11:49 |
| | | * @LastEditTime: 2024-06-16 16:17:45 |
| | | * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/system/vision-component-modify.vue |
| | | --> |
| | | <template> |
| | | <el-container> |
| | | <el-aside width="220px"> |
| | | <el-tree default-expand-all style="max-width: 600px" :data="treeData" :props="defaultProps" |
| | | @node-click="handleNodeClick" /> |
| | | </el-aside> |
| | | <el-container> |
| | | <el-header style="justify-content: flex-start;"> |
| | | <el-button type="primary" plain @click="add">新增</el-button> |
| | | <el-button @click="del" plain type="danger" :disabled="selection.length == 0">删除</el-button> |
| | | </el-header> |
| | | <el-main> |
| | | <scTable ref="table" @selection-change="handleSelectionChange" row-key="id" border :params="params" |
| | | :apiObj="apiObj" stripe> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="name" label="组件名称" /> |
| | | <el-table-column prop="typeName" label="分类名称" /> |
| | | <el-table-column prop="url" label="图片"> |
| | | <template #default="scope"> |
| | | <img style="width: 20px;height: 20px;" :src="`${host}${scope.row.url}`" alt="图片" srcset=""> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="orderNum" label="排列顺序" /> |
| | | <el-table-column label="操作" fixed="right" align="left" width="160"> |
| | | <template #default="scope"> |
| | | <el-button-group> |
| | | <el-button text type="primary" size="small" |
| | | @click="table_edit(scope.row, scope.$index)">编辑</el-button> |
| | | <el-popconfirm title="确定删除吗?" @confirm="table_del(scope.row, scope.$index, '0')"> |
| | | <template #reference> |
| | | <el-button text type="primary" size="small">删除</el-button> |
| | | </template> |
| | | </el-popconfirm> |
| | | </el-button-group> |
| | | </template> |
| | | </el-table-column> |
| | | </scTable> |
| | | </el-main> |
| | | </el-container> |
| | | <el-dialog v-model="dialogVisible" :title="dialogTitle" width="1000"> |
| | | <el-form :model="row" :rules="rules" ref="dialogForm" label-width="120px" label-position="center"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="组件名称" prop="name"> |
| | | <el-input style="width: 100%" v-model="row.name" placeholder="请输入" clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="分类名称" prop="typeName"> |
| | | <el-tree-select v-model="row.typeName" :data="treeData" :props="defaultProps" @node-click="nodeClick" |
| | | style="width: 240px" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" :data-url="`${host}${row.url}`"> |
| | | <el-form-item label="图片" prop="url"> |
| | | <scUpload v-model="row.url" :host="host"></scUpload> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="排列顺序" prop="orderNum"> |
| | | <el-input-number v-model="row.orderNum" :min="0" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" style="height: 300px;"> |
| | | <el-card shadow="never" header="javascript Darcula主题"> |
| | | <sc-code-editor v-model="row.component" mode="javascript" theme="darcula"></sc-code-editor> |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="dialogVisible = false">取消</el-button> |
| | | <el-button type="primary" @click="save"> |
| | | 保存 |
| | | </el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </el-container> |
| | | <el-main> |
| | | <el-card shadow="never"> |
| | | <el-container> |
| | | <el-aside width="220px"> |
| | | <el-tree :expand-on-click-node="false" default-expand-all style="max-width: 600px" :data="treeData" |
| | | :props="defaultProps" @node-click="handleNodeClick" /> |
| | | </el-aside> |
| | | <el-container> |
| | | <el-header style="justify-content: flex-start;"> |
| | | <el-button type="primary" plain @click="add">新增</el-button> |
| | | <el-button @click="del" plain type="danger" :disabled="selection.length == 0">删除</el-button> |
| | | </el-header> |
| | | <el-main> |
| | | <scTable ref="table" @selection-change="handleSelectionChange" row-key="id" border |
| | | :params="params" :apiObj="apiObj" stripe> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="name" label="组件名称" /> |
| | | <el-table-column prop="typeName" label="分类名称" /> |
| | | <el-table-column prop="url" label="图片"> |
| | | <template #default="scope"> |
| | | <img style="width: 20px;height: 20px;" :src="`${host}${scope.row.url}`" alt="图片" |
| | | srcset=""> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="orderNum" label="排列顺序" /> |
| | | <el-table-column label="操作" fixed="right" align="left" width="160"> |
| | | <template #default="scope"> |
| | | <el-button-group> |
| | | <el-button text type="primary" size="small" |
| | | @click="table_edit(scope.row, scope.$index)">编辑</el-button> |
| | | <el-popconfirm title="确定删除吗?" |
| | | @confirm="table_del(scope.row, scope.$index, '0')"> |
| | | <template #reference> |
| | | <el-button text type="primary" size="small">删除</el-button> |
| | | </template> |
| | | </el-popconfirm> |
| | | </el-button-group> |
| | | </template> |
| | | </el-table-column> |
| | | </scTable> |
| | | </el-main> |
| | | </el-container> |
| | | <el-dialog v-model="dialogVisible" :title="dialogTitle" width="1000"> |
| | | <el-form :model="row" :rules="rules" ref="dialogForm" label-width="120px" label-position="center"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="组件名称" prop="name"> |
| | | <el-input style="width: 100%" v-model="row.name" placeholder="请输入" |
| | | clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="分类名称" prop="typeName"> |
| | | <el-tree-select v-model="row.typeName" :data="treeData" :props="defaultProps" |
| | | @node-click="nodeClick" style="width: 240px" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" :data-url="`${host}${row.url}`"> |
| | | <el-form-item label="图片" prop="url"> |
| | | <scUpload v-model="row.url" :host="host"></scUpload> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="排列顺序" prop="orderNum"> |
| | | <el-input-number v-model="row.orderNum" :min="0" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" style="height: 300px;"> |
| | | <el-card shadow="never" header="javascript Darcula主题"> |
| | | <sc-code-editor v-model="row.component" mode="javascript" |
| | | theme="darcula"></sc-code-editor> |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="dialogVisible = false">取消</el-button> |
| | | <el-button type="primary" @click="save"> |
| | | 保存 |
| | | </el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </el-container> |
| | | </el-card> |
| | | </el-main> |
| | | </template> |
| | | |
| | | <script> |
| | |
| | | if (valid) { |
| | | let request = this.$API.setting.component.add |
| | | let data = { |
| | | ...this.row |
| | | } |
| | | ...this.row |
| | | } |
| | | if (this?.row?.id) { |
| | | request = this.$API.setting.component.update |
| | | } else { |
| | | |
| | | |
| | | delete data.id |
| | | } |
| | | request.post(data).then(res => { |
| | |
| | | this.dialogVisible = true |
| | | this.dialogTitle = '编辑' |
| | | }, |
| | | nodeClick (node) { |
| | | nodeClick(node) { |
| | | this.$nextTick(() => { |
| | | console.log(node) |
| | | if (node.hasChildren) return |
| | |
| | | this.row.typeName = node.name |
| | | console.log(this.row) |
| | | }) |
| | | |
| | | |
| | | }, |
| | | handleAvatarSuccess () {}, |
| | | beforeAvatarUpload () {}, |
| | | handleAvatarSuccess() { }, |
| | | beforeAvatarUpload() { }, |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .avatar { |
| | | width: 200px; |
| | | height:200px; |
| | | } |
| | | .avatar { |
| | | width: 200px; |
| | | height: 200px; |
| | | } |
| | | </style> |