| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <div class="app-container">
|
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
|
| | | <el-form-item label="é¨é¨åç§°" prop="deptName">
|
| | | <el-input
|
| | | v-model="queryParams.deptName"
|
| | | placeholder="请è¾å
¥é¨é¨åç§°"
|
| | | clearable
|
| | | style="width: 200px"
|
| | | @keyup.enter="handleQuery"
|
| | | />
|
| | | </el-form-item>
|
| | | <el-form-item label="ç¶æ" prop="status">
|
| | | <el-select v-model="queryParams.status" placeholder="é¨é¨ç¶æ" clearable style="width: 200px">
|
| | | <el-option
|
| | | v-for="dict in sys_normal_disable"
|
| | | :key="dict.value"
|
| | | :label="dict.label"
|
| | | :value="dict.value"
|
| | | />
|
| | | </el-select>
|
| | | </el-form-item>
|
| | | <el-form-item>
|
| | | <el-button type="primary" icon="Search" @click="handleQuery">æç´¢</el-button>
|
| | | <el-button icon="Refresh" @click="resetQuery">éç½®</el-button>
|
| | | </el-form-item>
|
| | | </el-form>
|
| | | |
| | | <el-row :gutter="10" class="mb8">
|
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="primary"
|
| | | plain
|
| | | icon="Plus"
|
| | | @click="handleAdd"
|
| | | v-hasPermi="['system:dept:add']"
|
| | | >æ°å¢</el-button>
|
| | | </el-col>
|
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="info"
|
| | | plain
|
| | | icon="Sort"
|
| | | @click="toggleExpandAll"
|
| | | >å±å¼/æå </el-button>
|
| | | </el-col>
|
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
| | | </el-row>
|
| | | <el-table
|
| | | v-if="refreshTable"
|
| | | v-loading="loading"
|
| | | :data="deptList"
|
| | | row-key="deptId"
|
| | | :default-expand-all="isExpandAll"
|
| | | :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
| | | >
|
| | | <el-table-column prop="deptName" label="é¨é¨åç§°" width="260"></el-table-column>
|
| | | <el-table-column prop="orderNum" label="æåº" width="200"></el-table-column>
|
| | | <el-table-column prop="status" label="ç¶æ" width="100">
|
| | | <template #default="scope">
|
| | | <dict-tag :options="sys_normal_disable" :value="scope.row.status" />
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column label="å建æ¶é´" align="center" prop="createTime" width="200">
|
| | | <template #default="scope">
|
| | | <span>{{ parseTime(scope.row.createTime) }}</span>
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column label="æä½" align="center" class-name="small-padding fixed-width">
|
| | | <template #default="scope">
|
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dept:edit']">ä¿®æ¹</el-button>
|
| | | <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']">æ°å¢</el-button>
|
| | | <el-button v-if="scope.row.parentId != 0" link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dept:remove']">å é¤</el-button>
|
| | | </template>
|
| | | </el-table-column>
|
| | | </el-table>
|
| | | |
| | | <!-- æ·»å æä¿®æ¹é¨é¨å¯¹è¯æ¡ -->
|
| | | <el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
| | | <el-form ref="deptRef" :model="form" :rules="rules" label-width="80px">
|
| | | <el-row>
|
| | | <el-col :span="24" v-if="form.parentId !== 0">
|
| | | <el-form-item label="ä¸çº§é¨é¨" prop="parentId">
|
| | | <el-tree-select
|
| | | v-model="form.parentId"
|
| | | :data="deptOptions"
|
| | | :props="{ value: 'deptId', label: 'deptName', children: 'children' }"
|
| | | value-key="deptId"
|
| | | placeholder="éæ©ä¸çº§é¨é¨"
|
| | | check-strictly
|
| | | />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12">
|
| | | <el-form-item label="é¨é¨åç§°" prop="deptName">
|
| | | <el-input v-model="form.deptName" placeholder="请è¾å
¥é¨é¨åç§°" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12">
|
| | | <el-form-item label="æ¾ç¤ºæåº" prop="orderNum">
|
| | | <el-input-number v-model="form.orderNum" controls-position="right" :min="0"/>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12">
|
| | | <el-form-item label="è´è´£äºº" prop="leader">
|
| | | <el-input v-model="form.leader" placeholder="请è¾å
¥è´è´£äºº" maxlength="20" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12">
|
| | | <el-form-item label="èç³»çµè¯" prop="phone">
|
| | | <el-input v-model="form.phone" placeholder="请è¾å
¥èç³»çµè¯" maxlength="11" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12">
|
| | | <el-form-item label="é®ç®±" prop="email">
|
| | | <el-input v-model="form.email" placeholder="请è¾å
¥é®ç®±" maxlength="50" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12">
|
| | | <el-form-item label="é¨é¨ç¶æ">
|
| | | <el-radio-group v-model="form.status">
|
| | | <el-radio
|
| | | v-for="dict in sys_normal_disable"
|
| | | :key="dict.value"
|
| | | :value="dict.value"
|
| | | >{{ dict.label }}</el-radio>
|
| | | </el-radio-group>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12">
|
| | | <el-form-item label="é¨é¨ç¼å·" prop="deptNick">
|
| | | <el-input v-model="form.deptNick" placeholder="请è¾å
¥é¨é¨ç¼å·" maxlength="50" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | </el-row>
|
| | | </el-form>
|
| | | <template #footer>
|
| | | <div class="dialog-footer">
|
| | | <el-button type="primary" @click="submitForm">ç¡® å®</el-button>
|
| | | <el-button @click="cancel">å æ¶</el-button>
|
| | | </div>
|
| | | </template>
|
| | | </el-dialog>
|
| | | </div>
|
| | | </template>
|
| | |
|
| | | <script setup name="Dept">
|
| | | import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"
|
| | |
|
| | | const { proxy } = getCurrentInstance()
|
| | | const { sys_normal_disable } = proxy.useDict("sys_normal_disable")
|
| | |
|
| | | const deptList = ref([])
|
| | | const open = ref(false)
|
| | | const loading = ref(true)
|
| | | const showSearch = ref(true)
|
| | | const title = ref("")
|
| | | const deptOptions = ref([])
|
| | | const isExpandAll = ref(true)
|
| | | const refreshTable = ref(true)
|
| | |
|
| | | const data = reactive({
|
| | | form: {},
|
| | | queryParams: {
|
| | | deptName: undefined,
|
| | | status: undefined
|
| | | },
|
| | | rules: {
|
| | | parentId: [{ required: true, message: "ä¸çº§é¨é¨ä¸è½ä¸ºç©º", trigger: "blur" }],
|
| | | deptName: [{ required: true, message: "é¨é¨åç§°ä¸è½ä¸ºç©º", trigger: "blur" }],
|
| | | orderNum: [{ required: true, message: "æ¾ç¤ºæåºä¸è½ä¸ºç©º", trigger: "blur" }],
|
| | | email: [{ type: "email", message: "请è¾å
¥æ£ç¡®çé®ç®±å°å", trigger: ["blur", "change"] }],
|
| | | phone: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请è¾å
¥æ£ç¡®çææºå·ç ", trigger: "blur" }],
|
| | | deptNick: [{ required: true, message: "é¨é¨ç¼å·ä¸è½ä¸ºç©º", trigger: "blur" }],
|
| | | },
|
| | | })
|
| | |
|
| | | const { queryParams, form, rules } = toRefs(data)
|
| | |
|
| | | /** æ¥è¯¢é¨é¨å表 */
|
| | | function getList() {
|
| | | loading.value = true
|
| | | listDept(queryParams.value).then(response => {
|
| | | deptList.value = proxy.handleTree(response.data, "deptId")
|
| | | loading.value = false
|
| | | })
|
| | | }
|
| | |
|
| | | /** åæ¶æé® */
|
| | | function cancel() {
|
| | | open.value = false
|
| | | reset()
|
| | | }
|
| | |
|
| | | /** 表åéç½® */
|
| | | function reset() {
|
| | | form.value = {
|
| | | deptId: undefined,
|
| | | parentId: undefined,
|
| | | deptName: undefined,
|
| | | orderNum: 0,
|
| | | leader: undefined,
|
| | | phone: undefined,
|
| | | email: undefined,
|
| | | status: "0",
|
| | | deptNick: undefined,
|
| | | }
|
| | | proxy.resetForm("deptRef")
|
| | | }
|
| | |
|
| | | /** æç´¢æé®æä½ */
|
| | | function handleQuery() {
|
| | | getList()
|
| | | }
|
| | |
|
| | | /** éç½®æé®æä½ */
|
| | | function resetQuery() {
|
| | | proxy.resetForm("queryRef")
|
| | | handleQuery()
|
| | | }
|
| | |
|
| | | /** æ°å¢æé®æä½ */
|
| | | function handleAdd(row) {
|
| | | reset()
|
| | | listDept().then(response => {
|
| | | deptOptions.value = proxy.handleTree(response.data, "deptId")
|
| | | })
|
| | | if (row != undefined) {
|
| | | form.value.parentId = row.deptId
|
| | | }
|
| | | open.value = true
|
| | | title.value = "æ·»å é¨é¨"
|
| | | }
|
| | |
|
| | | /** å±å¼/æå æä½ */
|
| | | function toggleExpandAll() {
|
| | | refreshTable.value = false
|
| | | isExpandAll.value = !isExpandAll.value
|
| | | nextTick(() => {
|
| | | refreshTable.value = true
|
| | | })
|
| | | }
|
| | |
|
| | | /** ä¿®æ¹æé®æä½ */
|
| | | function handleUpdate(row) {
|
| | | reset()
|
| | | listDeptExcludeChild(row.deptId).then(response => {
|
| | | deptOptions.value = proxy.handleTree(response.data, "deptId")
|
| | | })
|
| | | getDept(row.deptId).then(response => {
|
| | | form.value = response.data
|
| | | open.value = true
|
| | | title.value = "ä¿®æ¹é¨é¨"
|
| | | })
|
| | | }
|
| | |
|
| | | /** æäº¤æé® */
|
| | | function submitForm() {
|
| | | proxy.$refs["deptRef"].validate(valid => {
|
| | | if (valid) {
|
| | | if (form.value.deptId != undefined) {
|
| | | updateDept(form.value).then(response => {
|
| | | proxy.$modal.msgSuccess("ä¿®æ¹æå")
|
| | | open.value = false
|
| | | getList()
|
| | | })
|
| | | } else {
|
| | | addDept(form.value).then(response => {
|
| | | proxy.$modal.msgSuccess("æ°å¢æå")
|
| | | open.value = false
|
| | | getList()
|
| | | })
|
| | | }
|
| | | }
|
| | | })
|
| | | }
|
| | |
|
| | | /** å é¤æé®æä½ */
|
| | | function handleDelete(row) {
|
| | | proxy.$modal.confirm('æ¯å¦ç¡®è®¤å é¤å称为"' + row.deptName + '"çæ°æ®é¡¹?').then(function() {
|
| | | return delDept(row.deptId)
|
| | | }).then(() => {
|
| | | getList()
|
| | | proxy.$modal.msgSuccess("å 餿å")
|
| | | }).catch(() => {})
|
| | | }
|
| | |
|
| | | getList()
|
| | | </script>
|