index.vue 13 KB

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