index.vue 17 KB

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