| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- <template>
- <div class="app-container">
- <el-form
- :model="queryParams"
- ref="queryForm"
- size="small"
- :inline="true"
- v-show="showSearch"
- >
- <el-form-item label="单位编号" prop="unitId">
- <el-input
- v-model="queryParams.unitId"
- placeholder="请输入单位编号"
- clearable
- oninput="value=value.replace(/[^\d.]/g,'')"
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="单位名称" prop="unitName">
- <el-input
- v-model="queryParams.unitName"
- placeholder="请输入单位名称"
- clearable
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="状态" prop="status">
- <el-select
- v-model="queryParams.status"
- placeholder="状态"
- clearable
- style="width: 240px"
- >
- <el-option
- v-for="dict in dict.type.sys_normal_disable"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button
- v-no-more-click
- type="primary"
- icon="el-icon-search"
- size="mini"
- @click="handleQuery"
- >搜索
- </el-button>
- <el-button
- v-no-more-click
- icon="el-icon-refresh"
- size="mini"
- @click="resetQuery"
- >重置</el-button
- >
- </el-form-item>
- </el-form>
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- v-no-more-click
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="handleAdd"
- v-hasPermi="['iscs:unit:add']"
- >新增
- </el-button>
- </el-col>
- <!-- <el-col :span="1.5">-->
- <!-- <el-button v-no-more-click-->
- <!-- type="info"-->
- <!-- plain-->
- <!-- icon="el-icon-sort"-->
- <!-- size="mini"-->
- <!-- @click="toggleExpandAll"-->
- <!-- >展开/折叠-->
- <!-- </el-button>-->
- <!-- </el-col>-->
- <right-toolbar
- :showSearch.sync="showSearch"
- @queryTable="getList"
- ></right-toolbar>
- </el-row>
- <el-table
- v-if="refreshTable"
- v-loading="loading"
- :data="deptList"
- row-key="unitId"
- :default-expand-all="isExpandAll"
- :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
- >
- <el-table-column
- prop="unitId"
- label="单位编号"
- width="130"
- ></el-table-column>
- <el-table-column
- prop="unitName"
- label="单位名称"
- width="260"
- ></el-table-column>
- <el-table-column
- prop="unitType"
- label="单位类型"
- width="260"
- ></el-table-column>
- <el-table-column
- prop="orderNum"
- label="排序"
- width="200"
- ></el-table-column>
- <el-table-column prop="remark" label="备注" width="260"></el-table-column>
- <el-table-column prop="status" label="状态" width="150">
- <template slot-scope="scope">
- <el-switch
- v-model="scope.row.status"
- active-value="0"
- inactive-value="1"
- @change="handleStatusChange(scope.row)"
- ></el-switch>
- </template>
- </el-table-column>
- <!-- <el-table-column label="创建时间" align="center" prop="createTime" width="200">-->
- <!-- <template slot-scope="scope">-->
- <!-- <span>{{ scope.row.createTime }}</span>-->
- <!-- </template>-->
- <!-- </el-table-column>-->
- <el-table-column
- label="操作"
- align="center"
- class-name="small-padding fixed-width"
- >
- <template slot-scope="scope">
- <el-button
- v-no-more-click
- size="mini"
- type="text"
- icon="el-icon-edit"
- @click="handleUpdate(scope.row)"
- v-hasPermi="['iscs:unit:edit']"
- >修改
- </el-button>
- <!-- <el-button v-no-more-click-->
- <!-- size="mini"-->
- <!-- type="text"-->
- <!-- icon="el-icon-plus"-->
- <!-- @click="handleAdd(scope.row)"-->
- <!-- v-hasPermi="['iscs:unit:add']"-->
- <!-- >新增-->
- <!-- </el-button>-->
- <!-- v-if="scope.row.parentId != 0"-->
- <el-button
- v-no-more-click
- size="mini"
- type="text"
- icon="el-icon-delete"
- @click="handleDelete(scope.row)"
- v-hasPermi="['iscs:unit:remove']"
- >删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total > 0"
- :total="total"
- :page.sync="queryParams.current"
- :limit.sync="queryParams.size"
- @pagination="getList"
- />
- <!-- 添加或修改单位对话框 -->
- <el-dialog :title="title" :visible.sync="open" width="400px" append-to-body>
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
- <!-- <el-form-item label="上级" prop="parentId" v-if="form.parentId !== 0">-->
- <!-- <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级"/>-->
- <!-- </el-form-item>-->
- <el-form-item label="单位名称" prop="unitName">
- <el-input v-model="form.unitName" placeholder="请输入单位名称" />
- </el-form-item>
- <el-form-item label="单位类型" prop="unitType">
- <el-radio-group v-model="form.unitType">
- <el-radio label="内部">内部</el-radio>
- <el-radio label="外部">外部</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="排序" prop="orderNum">
- <el-input-number type="number" v-model="form.orderNum" />
- </el-form-item>
- <el-form-item label="备注" prop="remark">
- <el-input v-model="form.remark" placeholder="请输入备注" />
- </el-form-item>
- <el-form-item label="状态" prop="status">
- <el-radio-group v-model="form.status">
- <el-radio
- v-for="dict in dict.type.sys_normal_disable"
- :key="dict.value"
- :label="dict.value"
- >{{ dict.label }}</el-radio
- >
- </el-radio-group>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button v-no-more-click type="primary" @click="submitForm"
- >确 定</el-button
- >
- <el-button v-no-more-click @click="cancel">取 消</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- listUnit,
- getUnitInfo,
- addUnit,
- updateUnit,
- delUnit,
- } from "@/api/system/unit";
- import Treeselect from "@riophae/vue-treeselect";
- import "@riophae/vue-treeselect/dist/vue-treeselect.css";
- import { genCode } from "@/api/system/autocode/rule";
- import { updateMarsDeptStatus } from "@/api/system/marsdept";
- export default {
- name: "Dept",
- dicts: ["sys_normal_disable"],
- components: { Treeselect },
- data() {
- return {
- // 遮罩层
- loading: true,
- //自动生成编码
- autoGenFlag: false,
- // 显示搜索条件
- showSearch: true,
- total: 0, //
- // 表格树数据
- deptList: [],
- // 单位树选项
- deptOptions: [],
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- // 是否展开,默认全部展开
- isExpandAll: true,
- // 重新渲染表格状态
- refreshTable: true,
- // 查询参数
- queryParams: {
- current: 1,
- size: 10,
- unitName: undefined,
- userId: undefined,
- unitId: undefined,
- status: undefined,
- },
- // 表单参数
- form: {},
- // 表单校验
- rules: {
- // parentId: [
- // { required: true, message: '上级不能为空', trigger: 'blur' }
- // ],
- unitName: [
- { required: true, message: "单位名称不能为空", trigger: "blur" },
- ],
- },
- };
- },
- created() {
- this.getList();
- },
- methods: {
- // 用户状态修改
- handleStatusChange(row) {
- let text = row.status === "0" ? "启用" : "停用";
- this.$modal
- .confirm('确认要"' + text + '""' + row.unitName + '"岗位吗?')
- .then(function () {
- const data = {
- unitId: row.unitId,
- unitName: row.unitName,
- unitType: row.unitType,
- orderNum: row.orderNum,
- status: row.status,
- };
- return updateUnit(data);
- })
- .then(() => {
- this.$modal.msgSuccess(text + "成功");
- })
- .catch(function () {
- row.status = row.status === "0" ? "1" : "0";
- });
- },
- /** 查询单位列表 */
- getList() {
- this.loading = true;
- listUnit(this.queryParams).then((response) => {
- debugger;
- this.deptList = this.handleTree(
- response.data.records,
- "unitId",
- "parentId"
- );
- console.log(this.deptList, "单位列表");
- this.loading = false;
- this.total = response.data.total;
- });
- },
- /** 转换单位数据结构 */
- normalizer(node) {
- if (node.children && !node.children.length) {
- delete node.children;
- }
- return {
- id: node.unitId,
- label: node.unitName,
- children: node.children,
- };
- },
- // 取消按钮
- cancel() {
- this.open = false;
- this.reset();
- },
- // 表单重置
- reset() {
- this.form = {
- unitId: undefined,
- parentId: undefined,
- unitName: undefined,
- };
- this.autoGenFlag = false;
- this.resetForm("form");
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.resetForm("queryForm");
- this.handleQuery();
- },
- /** 新增按钮操作 */
- handleAdd(row) {
- this.reset();
- if (row != null && row.unitId) {
- this.form.parentId = row.unitId;
- } else {
- this.form.parentId = 0;
- }
- this.open = true;
- this.title = "新增单位";
- listUnit(this.queryParams).then((response) => {
- this.deptOptions = this.handleTree(
- response.data.records,
- "unitId",
- "parentId"
- );
- });
- },
- /** 展开/折叠操作 */
- toggleExpandAll() {
- this.refreshTable = false;
- this.isExpandAll = !this.isExpandAll;
- this.$nextTick(() => {
- this.refreshTable = true;
- });
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- this.reset();
- getUnitInfo(row.unitId).then((response) => {
- this.form = response.data;
- if (this.form.parentId == 0) {
- this.form.parentId = undefined;
- }
- this.open = true;
- this.title = "修改单位";
- });
- },
- /** 提交按钮 */
- submitForm: function () {
- this.$refs["form"].validate((valid) => {
- if (valid) {
- if (this.form.unitId != undefined) {
- updateUnit(this.form).then((response) => {
- this.$modal.msgSuccess("修改成功");
- this.open = false;
- this.getList();
- });
- } else {
- addUnit(this.form).then((response) => {
- this.$modal.msgSuccess("新增成功");
- this.open = false;
- this.getList();
- });
- }
- }
- });
- },
- /** 删除按钮操作 */
- // .confirm('是否确认删除名称为"' + row.unitName + '"的数据项?')
- handleDelete(row) {
- this.$modal
- .confirm("是否确认删除所选数据项?")
- .then(function () {
- return delUnit(row.unitId);
- })
- .then(() => {
- this.getList();
- this.$modal.msgSuccess("删除成功");
- })
- .catch(() => {});
- },
- },
- };
- </script>
|