index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--机构数据-->
  5. <!-- <el-col :span="4" :xs="24">
  6. <org-tree
  7. v-model="queryParams.orgId"
  8. @defaultKey="getDefaultKey"
  9. @checkChange="checkChange"
  10. @click="clickTreeNode"
  11. businessTree
  12. ></org-tree>
  13. </el-col> -->
  14. <el-col :span="24" :xs="24">
  15. <div class="main-right-box">
  16. <div class="main-search-box">
  17. <el-form
  18. :model="queryParams"
  19. ref="queryForm"
  20. size="small"
  21. :inline="true"
  22. v-show="showSearch"
  23. >
  24. <el-form-item label="机构名称">
  25. <org-tree
  26. v-model="queryParams.orgId"
  27. @defaultOrg="getDefaultOrg"
  28. @checkChange="checkChange"
  29. @click="clickTreeNode"
  30. ref="orgTree"
  31. ></org-tree>
  32. </el-form-item>
  33. <el-form-item label="机构类型" prop="orgType">
  34. <el-select
  35. v-model="queryParams.orgType"
  36. clearable
  37. placeholder="请选择机构类型"
  38. style="width: 100%"
  39. >
  40. <el-option
  41. v-for="dict in dict.type.sys_org_type"
  42. :key="dict.value"
  43. :label="dict.label"
  44. :value="dict.value"
  45. />
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item label="区域名称" prop="areaName">
  49. <el-input
  50. v-model="queryParams.areaName"
  51. placeholder="请输入区域名称"
  52. :maxlength="50"
  53. clearable
  54. @keyup.enter.native="handleQuery"
  55. />
  56. </el-form-item>
  57. <el-form-item label="标签编号" prop="code">
  58. <el-input
  59. maxlength="50"
  60. v-model="queryParams.code"
  61. placeholder="请输入标签编号"
  62. clearable
  63. @keyup.enter.native="handleQuery"
  64. />
  65. </el-form-item>
  66. <el-form-item label="状态" prop="enable">
  67. <el-select
  68. v-model="queryParams.enable"
  69. placeholder="请选择状态"
  70. >
  71. <el-option
  72. v-for="dict in dict.type.plan_status"
  73. :key="dict.value"
  74. :label="dict.label"
  75. :value="dict.value"
  76. ></el-option>
  77. </el-select>
  78. </el-form-item>
  79. </el-form>
  80. <el-row :gutter="10">
  81. <el-col :span="1.5">
  82. <el-button
  83. type="primary"
  84. icon="el-icon-search"
  85. size="mini"
  86. @click="handleQuery"
  87. >搜索</el-button
  88. >
  89. </el-col>
  90. <el-col :span="1.5">
  91. <el-button
  92. type="primary"
  93. icon="el-icon-refresh"
  94. size="mini"
  95. @click="resetQuery"
  96. >重置</el-button
  97. >
  98. </el-col>
  99. <el-col :span="1.5">
  100. <el-button
  101. type="primary"
  102. icon="el-icon-plus"
  103. size="mini"
  104. @click="handleAdd"
  105. v-hasPermi="['system:bind:add']"
  106. >新增</el-button
  107. >
  108. </el-col>
  109. <right-toolbar
  110. :showSearch.sync="showSearch"
  111. @queryTable="getList"
  112. ></right-toolbar>
  113. </el-row>
  114. </div>
  115. <el-table
  116. border
  117. height="646"
  118. size="small"
  119. v-loading="loading"
  120. :data="bindList"
  121. @selection-change="handleSelectionChange"
  122. >
  123. <el-table-column label="序号" align="center" width="60">
  124. <template v-slot:default="scope">
  125. <span v-text="getPageIndex(scope.$index)"> </span>
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="机构名称" align="left" prop="orgName" />
  129. <el-table-column label="区域名称" align="left" prop="areaName" />
  130. <el-table-column
  131. label="NFC点位"
  132. align="left"
  133. prop="collectionAreaName"
  134. />
  135. <el-table-column label="标签编号" align="left" prop="code" />
  136. <el-table-column label="标签名称" align="left" prop="labelName" />
  137. <el-table-column prop="status" label="状态" width="80">
  138. <template slot-scope="scope">
  139. <dict-tag
  140. :options="dict.type.plan_status"
  141. :value="scope.row.enable"
  142. />
  143. </template>
  144. </el-table-column>
  145. <el-table-column
  146. label="创建时间"
  147. align="center"
  148. prop="createTime"
  149. width="200"
  150. />
  151. <el-table-column
  152. label="更新时间"
  153. align="center"
  154. prop="updateTime"
  155. width="200"
  156. />
  157. <el-table-column
  158. label="操作"
  159. align="center"
  160. class-name="small-padding fixed-width"
  161. >
  162. <template slot-scope="scope">
  163. <el-button
  164. size="mini"
  165. type="text"
  166. icon="el-icon-edit-outline"
  167. @click="handleUpdate(scope.row)"
  168. v-hasPermi="['system:bind:edit']"
  169. >编辑</el-button
  170. >
  171. <el-button
  172. size="mini"
  173. type="text"
  174. icon="el-icon-delete"
  175. @click="handleDelete(scope.row)"
  176. v-hasPermi="['system:bind:remove']"
  177. >删除</el-button
  178. >
  179. </template>
  180. </el-table-column>
  181. </el-table>
  182. <pagination
  183. v-show="total > 0"
  184. :total="total"
  185. :page.sync="queryParams.pageNum"
  186. :limit.sync="queryParams.pageSize"
  187. @pagination="getList"
  188. />
  189. </div>
  190. </el-col>
  191. </el-row>
  192. <!-- 添加或修改【请填写功能名称】对话框 -->
  193. <DialogCom :title="title" :visible.sync="open" width="500px" append-to-body>
  194. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  195. <el-form-item label="机构名称" prop="orgId">
  196. <treeselect
  197. v-model="form.orgId"
  198. :options="deptOptions"
  199. :show-count="true"
  200. :normalizer="tenantIdnormalizer"
  201. :props="{ checkStrictly: true, label: 'name' }"
  202. placeholder="请选择机构"
  203. noResultsText="暂无符合条件的数据"
  204. noOptionsText="无数据"
  205. @select="changeSelectArea"
  206. />
  207. </el-form-item>
  208. <el-form-item label="区域名称" prop="areaId">
  209. <el-select
  210. mode="multiple"
  211. style="width: 100%"
  212. v-model="form.areaId"
  213. :popper-append-to-body="false"
  214. placeholder="请选择区域名称"
  215. >
  216. <el-option
  217. v-for="item in roleOptions"
  218. :key="item.id"
  219. :label="item.name"
  220. :value="item.id"
  221. ></el-option>
  222. </el-select>
  223. </el-form-item>
  224. <el-form-item label="NFC点位" prop="checkId">
  225. <el-select
  226. style="width: 100%"
  227. v-model="form.checkId"
  228. :popper-append-to-body="false"
  229. placeholder="请选择NFC点位"
  230. >
  231. <el-option
  232. v-for="item in checkList"
  233. :key="item.id"
  234. :label="item.checkName"
  235. :value="item.id"
  236. ></el-option>
  237. </el-select>
  238. </el-form-item>
  239. <el-form-item label="标签编号" prop="code">
  240. <el-input
  241. maxlength="50"
  242. v-model="form.code"
  243. placeholder="请输入标签编号"
  244. />
  245. </el-form-item>
  246. <el-form-item label="标签名称" prop="labelName">
  247. <el-input
  248. v-model="form.labelName"
  249. placeholder="请输入标签名称"
  250. maxlength="50"
  251. />
  252. </el-form-item>
  253. <el-form-item label="状态" prop="enable">
  254. <el-select
  255. style="width: 100%"
  256. v-model="form.enable"
  257. :popper-append-to-body="false"
  258. placeholder="请选择状态"
  259. >
  260. <el-option
  261. v-for="dict in dict.type.plan_status"
  262. :key="dict.value"
  263. :label="dict.label"
  264. :value="`${dict.value}`"
  265. ></el-option>
  266. </el-select>
  267. </el-form-item>
  268. </el-form>
  269. <div slot="footer" class="dialog-footer">
  270. <el-button type="primary" @click="submitForm">确 定</el-button>
  271. <el-button @click="cancel">取 消</el-button>
  272. </div>
  273. </DialogCom>
  274. </div>
  275. </template>
  276. <script>
  277. import tableList from "@/mixins/tableList";
  278. import treeselect from "@riophae/vue-treeselect";
  279. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  280. import {
  281. listBind,
  282. getBind,
  283. delBind,
  284. addBind,
  285. updateBind,
  286. } from "@/api/system/bind";
  287. import { getAreaByOrg } from "@/api/system/area";
  288. import { deptTreeSelect, businessTreeSelect } from "@/api/system/public";
  289. import { getCheckByAreaId, getAreaCheckInfoByOrgId } from "@/api/system/check";
  290. import orgTree from "@/components/orgTree/orgQuerySelector.vue";
  291. import { mapGetters } from "vuex";
  292. export default {
  293. dicts: ["sys_normal_disable", "plan_status","sys_org_type"],
  294. /** 引入基础minxins*/
  295. mixins: [tableList],
  296. components: { treeselect, orgTree },
  297. data() {
  298. return {
  299. // 遮罩层
  300. loading: true,
  301. // 选中数组
  302. ids: [],
  303. // 总条数
  304. total: 0,
  305. names: [],
  306. //搜索tree
  307. deptName: null,
  308. // 非单个停用
  309. single: true,
  310. // 非多个停用
  311. multiple: true,
  312. // 显示搜索条件
  313. showSearch: true,
  314. // 部门树选项
  315. deptOptions: null,
  316. // 【请填写功能名称】表格数据
  317. bindList: [],
  318. // 弹出层标题
  319. title: "",
  320. // 是否显示弹出层
  321. open: false,
  322. // 查询参数
  323. queryParams: {
  324. pageNum: 1,
  325. pageSize: 10,
  326. areaId: null,
  327. enable: null,
  328. code: null,
  329. updateId: null,
  330. orgId: null,
  331. orgName: null,
  332. orgPath: null,
  333. collectionAreaName: null,
  334. checkId: null,
  335. checkSub: true,
  336. },
  337. // 表单参数
  338. form: {},
  339. // 表单校验
  340. rules: {
  341. areaId: [{ required: true, message: "请选择区域", trigger: "blur" }],
  342. orgId: [{ required: true, message: "请选择归属部门", trigger: "blur" }],
  343. checkId: [
  344. { required: true, message: "请选择NFC点位名称", trigger: "blur" },
  345. ],
  346. code: [
  347. { required: true, message: "请输入标签编号", trigger: "change" },
  348. ],
  349. enable: [{ required: true, message: "请选择状态", trigger: "blur" }],
  350. labelName: [
  351. { required: true, message: "请输入标签名称", trigger: "change" },
  352. ],
  353. },
  354. checkList: [],
  355. roleOptions: [],
  356. defaultKeys: [],
  357. //是否关联下级
  358. checked: false,
  359. defaultProps: {
  360. children: "children",
  361. label: "name",
  362. },
  363. };
  364. },
  365. computed: {
  366. ...mapGetters(["orgId"]),
  367. },
  368. watch: {
  369. // 根据名称筛选部门树
  370. deptName(val) {
  371. this.$refs.tree.filter(val);
  372. },
  373. },
  374. created() {
  375. // this.getDeptTree();
  376. },
  377. methods: {
  378. //单选框状态改变
  379. checkChange(state) {
  380. this.queryParams.checkSub = state;
  381. this.handleQuery();
  382. },
  383. // 节点单击事件
  384. clickTreeNode(data) {
  385. this.queryParams.orgId = data.id;
  386. this.handleQuery();
  387. },
  388. getPageIndex($index) {
  389. //表格序号
  390. return (
  391. (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
  392. );
  393. },
  394. closeOptions() {
  395. this.$refs.fuzzySearch[0].blur();
  396. },
  397. /** 下穿状态改变*/
  398. changeCheckBox() {
  399. this.getList();
  400. },
  401. // 筛选节点
  402. filterNode(value, data) {
  403. if (!value) return true;
  404. return data.name.indexOf(value) !== -1;
  405. },
  406. // 节点单击事件
  407. handleNodeClick(data) {
  408. this.queryParams.orgId = data.id;
  409. this.handleQuery();
  410. },
  411. changeSelectArea(val) {
  412. getAreaByOrg(val).then((response) => {
  413. this.roleOptions = response.data;
  414. this.form.areaId = null;
  415. if (response.code == 200) {
  416. getAreaCheckInfoByOrgId(val).then((response) => {
  417. this.form.checkId = null;
  418. this.checkList = response.data;
  419. });
  420. }
  421. });
  422. },
  423. // getDefaultKey(key) {
  424. // this.queryParams.orgId = key;
  425. // this.getList();
  426. // },
  427. // changeSelect(val) {
  428. // getCheckByAreaId(val).then(response => {
  429. // this.checkList = response.data;
  430. // })
  431. // getAreaCheckInfoByOrgId(val).then(response=>{
  432. // this.checkList = response.data;
  433. // })
  434. // },
  435. /** 查询【请填写功能名称】列表 */
  436. getList() {
  437. this.loading = true;
  438. listBind(this.queryParams).then((response) => {
  439. this.bindList = response.rows;
  440. this.total = response.total;
  441. this.loading = false;
  442. });
  443. },
  444. getDefaultOrg(node) {
  445. this.queryParams.orgId = node.id;
  446. this.selectedOrgName = node.shortName;
  447. this.getList();
  448. },
  449. //单选框状态改变
  450. checkChange(state) {
  451. this.queryParams.checkSub = state;
  452. this.getList();
  453. },
  454. // 节点单击事件
  455. clickTreeNode(data) {
  456. if(data==null){
  457. return;
  458. }
  459. this.queryParams.orgId = data.id;
  460. this.selectedOrgName = data.shortName;
  461. this.getList();
  462. },
  463. /** 查询部门下拉树结构 */
  464. // getDeptTree() {
  465. // // deptTreeSelect().then(response => {
  466. // // this.deptOptions = response.data;
  467. // // this.defaultKeys.push(response.data[0].id);
  468. // // this.queryParams.orgId = response.data[0].id;
  469. // // this.handleQuery();
  470. // // });
  471. // businessTreeSelect().then((response) => {
  472. // this.deptOptions = response.data;
  473. // this.defaultKeys.push(response.data[0].id);
  474. // this.queryParams.orgId = response.data[0].id;
  475. // this.handleQuery();
  476. // });
  477. // },
  478. tenantIdnormalizer(node, instanceId) {
  479. if (node.children && !node.children.length) {
  480. delete node.children;
  481. }
  482. return {
  483. id: node.id,
  484. label: node.shortName,
  485. children: node.children,
  486. };
  487. },
  488. // 取消按钮
  489. cancel() {
  490. this.open = false;
  491. this.reset();
  492. },
  493. // 表单重置
  494. reset() {
  495. this.form = {
  496. id: null,
  497. areaId: null,
  498. enable: "0",
  499. code: null,
  500. createTime: null,
  501. updateId: null,
  502. updateBy: null,
  503. updateTime: null,
  504. orgId: null,
  505. orgName: null,
  506. orgPath: null,
  507. collectionAreaName: null,
  508. checkId: null,
  509. };
  510. this.resetForm("form");
  511. },
  512. /** 搜索按钮操作 */
  513. handleQuery() {
  514. this.queryParams.pageNum = 1;
  515. this.getList();
  516. },
  517. /** 重置按钮操作 */
  518. resetQuery() {
  519. this.resetForm("queryForm");
  520. this.queryParams.orgId = this.orgId;
  521. this.queryParams.checkSub = true;
  522. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub)
  523. this.handleQuery();
  524. },
  525. // 多选框选中数据
  526. handleSelectionChange(selection) {
  527. this.ids = selection.map((item) => item.id);
  528. this.names = selection.map((item) => item.code);
  529. this.single = selection.length !== 1;
  530. this.multiple = !selection.length;
  531. },
  532. /** 新增按钮操作 */
  533. handleAdd() {
  534. this.reset();
  535. // this.open = true;
  536. // this.title = "添加";
  537. getBind("").then((response) => {
  538. this.roleOptions = response.areas;
  539. this.open = true;
  540. this.title = "新增";
  541. this.form.password = this.initPassword;
  542. });
  543. },
  544. /** 修改按钮操作 */
  545. handleUpdate(row) {
  546. this.reset();
  547. const id = row.id || this.ids;
  548. getBind(id).then((response) => {
  549. this.form = response.data;
  550. this.roleOptions = response.areas;
  551. this.checkList = response.checks;
  552. this.open = true;
  553. this.title = "编辑";
  554. });
  555. },
  556. /** 提交按钮 */
  557. submitForm() {
  558. this.$refs["form"].validate((valid) => {
  559. if (valid) {
  560. if (this.form.id != null) {
  561. updateBind(this.form).then((response) => {
  562. this.$modal.msgSuccess("修改成功");
  563. this.open = false;
  564. this.getList();
  565. });
  566. } else {
  567. addBind(this.form).then((response) => {
  568. this.$modal.msgSuccess("新增成功");
  569. this.open = false;
  570. this.getList();
  571. });
  572. }
  573. }
  574. });
  575. },
  576. /** 删除按钮操作 */
  577. handleDelete(row) {
  578. const ids = row.id || this.ids;
  579. const names = row.code || this.names;
  580. this.$modal
  581. .confirm('是否确认删除标签编号为"' + names + '"的数据项?')
  582. .then(function () {
  583. return delBind(ids);
  584. })
  585. .then(() => {
  586. this.getList();
  587. this.$modal.msgSuccess("删除成功");
  588. })
  589. .catch(() => {});
  590. },
  591. /** 导出按钮操作 */
  592. handleExport() {
  593. this.download(
  594. "system/bind/export",
  595. {
  596. ...this.queryParams,
  597. },
  598. `bind_${new Date().getTime()}.xlsx`
  599. );
  600. },
  601. }
  602. };
  603. </script>