index.vue 15 KB

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