index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--机构数据-->
  5. <el-col :span="4" :xs="24">
  6. <div class="head-container">
  7. <el-input v-model="deptName" placeholder="请输入机构名称" clearable size="small" prefix-icon="el-icon-search"
  8. style="margin-bottom: 20px" />
  9. </div>
  10. <div class="tree-container">
  11. <div style="margin-bottom: 10px;">
  12. <el-checkbox v-model="queryParams.checkSub" @change="changeCheckBox">是否关联下级机构</el-checkbox>
  13. </div>
  14. <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false"
  15. :filter-node-method="filterNode" ref="tree" node-key="id" :default-expanded-keys="defaultKeys"
  16. :default-checked-keys="defaultKeys" @node-click="handleNodeClick" />
  17. </div>
  18. </el-col>
  19. <!--用户数据-->
  20. <el-col :span="20" :xs="24">
  21. <!-- 搜索条件 -->
  22. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
  23. <el-form-item label="机构名称" prop="name">
  24. <el-input v-model="queryParams.name" placeholder="请输入机构名称" clearable @keyup.enter.native="handleQuery" />
  25. </el-form-item>
  26. <el-form-item label="状态" prop="isLock">
  27. <el-select v-model="queryParams.isLock" placeholder="机构状态" clearable>
  28. <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
  29. :value="dict.value" />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  34. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  35. </el-form-item>
  36. </el-form>
  37. <el-row :gutter="10" class="mb8">
  38. <el-col :span="1.5">
  39. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="showDialogEdit(0)"
  40. v-hasPermi="['system:dept:add']">新增离行式自助银行</el-button>
  41. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd(row)"
  42. v-hasPermi="['system:dept:add']">新增中心业务库</el-button>
  43. </el-col>
  44. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  45. </el-row>
  46. <el-table v-loading="loading" :data="deptList" @selection-change="handleSelectionChange">
  47. <el-table-column label="序号" align="center" min-width="30">
  48. <template v-slot:default="scope">
  49. <span v-text="getPageIndex(scope.$index)"> </span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column prop="code" label="编码"></el-table-column>
  53. <el-table-column prop="type" label="机构类型">
  54. <template v-slot="scope">
  55. <dict-tag :options="dict.type.sys_org_type" :value="scope.row.type" />
  56. </template>
  57. </el-table-column>
  58. <el-table-column prop="name" label="机构名称"></el-table-column>
  59. <el-table-column prop="isLock" label="状态">
  60. <template v-slot="scope">
  61. <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.isLock" />
  62. </template>
  63. </el-table-column>
  64. <el-table-column prop="weatherCityCode" label="天气区域编码"></el-table-column>
  65. <el-table-column prop="address" label="地址"></el-table-column>
  66. <el-table-column label="负责人及电话" align="center">
  67. <template v-slot:default="scope">
  68. <span v-text="scope.row.manager"></span>-
  69. <span v-text="scope.row.managerPhone"> </span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  73. <template slot-scope="scope">
  74. <router-link :to="'/system/dept-extend/extend/' + scope.row.id" class="link-type">
  75. <el-button size="mini" type="text" icon="el-icon-plus"
  76. v-hasPermi="['system:dept:extend']">补充信息</el-button>
  77. </router-link>
  78. <el-button size="mini" type="text" icon="el-icon-edit" @click="showDialogEdit(scope.row)"
  79. v-hasPermi="['system:dept:edit']">修改</el-button>
  80. <el-button v-if="scope.row.parentId != 0" size="mini" type="text" icon="el-icon-delete"
  81. @click="handleDelete(scope.row)" v-hasPermi="['system:dept:remove']">删除</el-button>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  86. @pagination="getList" />
  87. </el-col>
  88. </el-row>
  89. <!-- 添加或修改机构对话框 -->
  90. <el-dialog :title="title" :visible.sync="open" width="600px" @close="closeHandler" append-to-body>
  91. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  92. <el-row>
  93. <el-col :span="24">
  94. <el-form-item v-if="this.pId !=-1" label="上级机构" prop="parentId">
  95. <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级机构" />
  96. </el-form-item>
  97. </el-col>
  98. </el-row>
  99. <el-row>
  100. <el-col :span="12">
  101. <el-form-item label="机构名称" prop="name">
  102. <el-input v-model="form.name" placeholder="请输入机构名称" />
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="12">
  106. <el-form-item label="显示排序" prop="sort">
  107. <el-input-number v-model="form.sort" controls-position="right" :min="0" />
  108. </el-form-item>
  109. </el-col>
  110. </el-row>
  111. <el-row>
  112. <el-col :span="12">
  113. <el-form-item label="负责人" prop="manager">
  114. <el-input v-model="form.manager" placeholder="请输入负责人" maxlength="20" />
  115. </el-form-item>
  116. </el-col>
  117. <el-col :span="12">
  118. <el-form-item label="联系电话" prop="phone">
  119. <el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" />
  120. </el-form-item>
  121. </el-col>
  122. </el-row>
  123. <el-row>
  124. <el-col :span="12" v-if="false">
  125. <el-form-item label="邮箱" prop="email">
  126. <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
  127. </el-form-item>
  128. </el-col>
  129. <el-col :span="12">
  130. <el-form-item label="机构状态" prop="isLock">
  131. <el-radio-group v-model="form.isLock">
  132. <el-radio v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.value">{{ dict.label
  133. }}</el-radio>
  134. </el-radio-group>
  135. </el-form-item>
  136. </el-col>
  137. </el-row>
  138. </el-form>
  139. <div slot="footer" class="dialog-footer">
  140. <el-button v-if="title == '修改机构'" type="primary" @click="changeSubmitForm">确 定</el-button>
  141. <el-button v-if="title == '添加机构'" type="primary" @click="addSubmitForm">确 定</el-button>
  142. <el-button @click="cancel">取 消</el-button>
  143. </div>
  144. </el-dialog>
  145. <DialogEdit ref="dialogEdit" ></DialogEdit>
  146. </div>
  147. </template>
  148. <script>
  149. import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept";
  150. import { deptTreeSelect } from "@/api/system/public";
  151. import Treeselect from "@riophae/vue-treeselect";
  152. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  153. import DialogEdit from "@/views/system/dept/dialog.edit.vue";
  154. export default {
  155. name: "Dept",
  156. dicts: ['sys_normal_disable', 'sys_org_type'],
  157. components: { Treeselect ,DialogEdit},
  158. data() {
  159. return {
  160. // 遮罩层
  161. loading: true,
  162. // 显示搜索条件
  163. showSearch: true,
  164. // 表格树数据
  165. deptList: [],
  166. // 总条数
  167. total: 0,
  168. // 机构树选项
  169. deptOptions: [],
  170. pId: 0,
  171. // 弹出层标题
  172. title: "",
  173. // 是否显示弹出层
  174. open: false,
  175. // 是否展开,默认全部展开
  176. isExpandAll: false,
  177. // 重新渲染表格状态
  178. refreshTable: true,
  179. // 机构名称
  180. deptName: undefined,
  181. //是否关联下级
  182. checked: false,
  183. defaultProps: {
  184. children: "children",
  185. label: "name"
  186. },
  187. // 查询参数
  188. queryParams: {
  189. pageNum: 1,
  190. pageSize: 10,
  191. name: undefined,
  192. status: undefined,
  193. parentId: undefined,
  194. },
  195. // 表单参数
  196. form: {},
  197. // 表单校验
  198. rules: {
  199. parentId: [
  200. { required: true, message: "上级机构不能为空", trigger: "blur" }
  201. ],
  202. name: [
  203. { required: true, message: "机构名称不能为空", trigger: "blur" }
  204. ],
  205. orderNum: [
  206. { required: true, message: "显示排序不能为空", trigger: "blur" }
  207. ],
  208. isLock: [
  209. { required: true, message: "状态不能为空", trigger: "blur" }
  210. ],
  211. email: [
  212. {
  213. type: "email",
  214. message: "请输入正确的邮箱地址",
  215. trigger: ["blur", "change"]
  216. }
  217. ],
  218. phone: [
  219. {
  220. pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
  221. message: "请输入正确的手机号码",
  222. trigger: "blur"
  223. }
  224. ]
  225. },
  226. //默认选中节点
  227. defaultKeys: []
  228. };
  229. },
  230. computed: {
  231. isShow() {
  232. if((this.pId==null&&this.pId!=-1)){
  233. return true
  234. }
  235. }
  236. },
  237. created() {
  238. this.getDeptTree();
  239. this.getList();
  240. },
  241. methods: {
  242. closeHandler(){
  243. // alert(11111)
  244. },
  245. getPageIndex($index) {
  246. //表格序号
  247. return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
  248. },
  249. //自定义数据
  250. tenantIdnormalizer(node, instanceId) {
  251. if (node.children && !node.children.length) {
  252. delete node.children
  253. }
  254. return {
  255. id: node.id,
  256. label: node.name,
  257. children: node.children
  258. }
  259. },
  260. /** 下穿状态改变*/
  261. changeCheckBox() {
  262. this.getList();
  263. },
  264. /** 查询机构下拉树结构 */
  265. getDeptTree() {
  266. deptTreeSelect().then(response => {
  267. this.deptOptions = response.data;
  268. this.defaultKeys.push(response.data[0].id);
  269. this.queryParams.parentId = response.data[0].id;
  270. this.handleQuery();
  271. });
  272. },
  273. // 筛选节点
  274. filterNode(value, data) {
  275. if (!value) return true;
  276. return data.name.indexOf(value) !== -1;
  277. },
  278. // 节点单击事件
  279. handleNodeClick(data) {
  280. this.queryParams.parentId = data.id;
  281. this.handleQuery();
  282. },
  283. /** 查询机构列表 */
  284. getList() {
  285. this.loading = true;
  286. listDept(this.queryParams).then(response => {
  287. this.deptList = response.rows;
  288. this.total = response.total;
  289. this.loading = false;
  290. });
  291. },
  292. /** 转换机构数据结构 */
  293. normalizer(node) {
  294. if (node.children && !node.children.length) {
  295. delete node.children;
  296. }
  297. return {
  298. id: node.id,
  299. label: node.name,
  300. children: node.children
  301. };
  302. },
  303. // 取消按钮
  304. cancel() {
  305. this.open = false;
  306. this.reset();
  307. },
  308. // 表单重置
  309. reset() {
  310. this.form = {
  311. deptId: undefined,
  312. parentId: undefined,
  313. deptName: undefined,
  314. orderNum: undefined,
  315. leader: undefined,
  316. phone: undefined,
  317. email: undefined,
  318. status: "0",
  319. isLock: "0"
  320. };
  321. this.resetForm("form");
  322. },
  323. /** 搜索按钮操作 */
  324. handleQuery() {
  325. this.getList();
  326. },
  327. /** 重置按钮操作 */
  328. resetQuery() {
  329. this.resetForm("queryForm");
  330. this.handleQuery();
  331. },
  332. /** 新增按钮操作 */
  333. handleAdd(row) {
  334. this.reset();
  335. if (this.queryParams.parentId != undefined) {
  336. this.form.parentId = this.queryParams.parentId;
  337. }
  338. this.open = true;
  339. this.title = "添加机构";
  340. },
  341. /** 展开/折叠操作 */
  342. toggleExpandAll() {
  343. this.refreshTable = false;
  344. this.isExpandAll = !this.isExpandAll;
  345. this.$nextTick(() => {
  346. this.refreshTable = true;
  347. });
  348. },
  349. /** 修改按钮操作 */
  350. handleUpdate(row) {
  351. this.reset();
  352. getDept(row.id).then(response => {
  353. this.form = response.data;
  354. this.pId = response.data.parentId;
  355. this.open = true;
  356. this.title = "修改机构";
  357. });
  358. if (this.pId != -1) {
  359. listDeptExcludeChild(row.id).then(response => {
  360. this.deptOptions = this.handleTree(response.data, "id");
  361. });
  362. }
  363. },
  364. /** 提交按钮 */
  365. changeSubmitForm() {
  366. this.$refs["form"].validate(valid => {
  367. if (valid) {
  368. updateDept(this.form).then(response => {
  369. this.$modal.msgSuccess("修改成功");
  370. this.open = false;
  371. this.getList();
  372. this.getDeptTree();
  373. });
  374. }
  375. });
  376. },
  377. addSubmitForm() {
  378. this.$refs["form"].validate(valid => {
  379. if (valid) {
  380. addDept(this.form).then(response => {
  381. this.$modal.msgSuccess("新增成功");
  382. this.open = false;
  383. this.getList();
  384. this.getDeptTree();
  385. });
  386. }
  387. });
  388. },
  389. /** 删除按钮操作 */
  390. handleDelete(row) {
  391. this.$modal.confirm('是否确认删除名称为"' + row.name + '"的数据项?').then(function () {
  392. return delDept(row.id);
  393. }).then(() => {
  394. this.getList();
  395. this.$modal.msgSuccess("删除成功");
  396. this.getDeptTree();
  397. }).catch(() => { });
  398. },
  399. // 多选框选中数据
  400. handleSelectionChange(selection) {
  401. this.ids = selection.map(item => item.userId);
  402. this.single = selection.length != 1;
  403. this.multiple = !selection.length;
  404. },
  405. showDialogEdit(row){
  406. console.log(row,33333333333)
  407. // row.id=row.orgid;
  408. this.$refs.dialogEdit.show(row);
  409. },
  410. },
  411. watch: {
  412. // 根据名称筛选机构树
  413. deptName(val) {
  414. this.$refs.tree.filter(val);
  415. }
  416. }
  417. };
  418. </script>
  419. <style lang="scss" scoped></style>