index.vue 17 KB

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