index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="机构类型" prop="orgType">
  5. <el-select
  6. v-model="queryParams.orgType"
  7. placeholder="请选择机构类型"
  8. clearable
  9. style="width: 100%"
  10. >
  11. <el-option
  12. v-for="dict in dict.type.sys_org_type"
  13. :key="dict.value"
  14. :label="dict.label"
  15. :value="dict.value"
  16. />
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="区域名称" prop="name">
  20. <el-input
  21. style="width: 100%"
  22. v-model="queryParams.name"
  23. placeholder="请输入区域名称"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  30. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <el-row :gutter="10" class="mb8">
  34. <el-col :span="1.5">
  35. <el-button
  36. type="primary"
  37. plain
  38. icon="el-icon-plus"
  39. size="mini"
  40. @click="handleAdd"
  41. v-hasPermi="['system:area:add']"
  42. >新增</el-button>
  43. </el-col>
  44. <el-col :span="1.5">
  45. <el-button
  46. type="success"
  47. plain
  48. icon="el-icon-edit"
  49. size="mini"
  50. :disabled="single"
  51. @click="handleUpdate"
  52. v-hasPermi="['system:area:edit']"
  53. >修改</el-button>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button
  57. type="danger"
  58. plain
  59. icon="el-icon-delete"
  60. size="mini"
  61. :disabled="multiple"
  62. @click="handleDelete"
  63. v-hasPermi="['system:area:remove']"
  64. >删除</el-button>
  65. </el-col>
  66. <!-- <el-col :span="1.5">
  67. <el-button
  68. type="warning"
  69. plain
  70. icon="el-icon-download"
  71. size="mini"
  72. @click="handleExport"
  73. v-hasPermi="['system:area:export']"
  74. >导出</el-button>
  75. </el-col> -->
  76. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  77. </el-row>
  78. <el-table v-loading="loading" :data="areaList" @selection-change="handleSelectionChange">
  79. <el-table-column type="selection" width="55" align="center" />
  80. <el-table-column label="区域名称" align="center" prop="name" />
  81. <el-table-column label="机构类型" align="center" prop="orgType" />
  82. <el-table-column label="更新人" align="center" prop="updateBy" />
  83. <el-table-column label="创建时间" align="center" prop="createTime" />
  84. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  85. <template slot-scope="scope">
  86. <el-button
  87. size="mini"
  88. type="text"
  89. icon="el-icon-edit"
  90. @click="handleUpdate(scope.row)"
  91. v-hasPermi="['system:area:edit']"
  92. >修改</el-button>
  93. <el-button
  94. size="mini"
  95. type="text"
  96. icon="el-icon-delete"
  97. @click="handleDelete(scope.row)"
  98. v-hasPermi="['system:area:remove']"
  99. >删除</el-button>
  100. </template>
  101. </el-table-column>
  102. </el-table>
  103. <pagination
  104. v-show="total>0"
  105. :total="total"
  106. :page.sync="queryParams.pageNum"
  107. :limit.sync="queryParams.pageSize"
  108. @pagination="getList"
  109. />
  110. <!-- 添加或修改【请填写功能名称】对话框 -->
  111. <DialogCom :title="title" :visible.sync="open" width="500px" append-to-body>
  112. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  113. <el-form-item label="区域名称" prop="name">
  114. <el-input maxlength="50" v-model="form.name" placeholder="请输入区域名称" />
  115. </el-form-item>
  116. <el-form-item label="机构类型" prop="orgType">
  117. <el-select v-model="form.orgType" placeholder="请选择机构类型">
  118. <el-option
  119. v-for="dict in dict.type.sys_org_type"
  120. :key="dict.value"
  121. :label="dict.label"
  122. :value="`${dict.value}`"
  123. ></el-option>
  124. </el-select>
  125. </el-form-item>
  126. </el-form>
  127. <div slot="footer" class="dialog-footer">
  128. <el-button type="primary" @click="submitForm">确 定</el-button>
  129. <el-button @click="cancel">取 消</el-button>
  130. </div>
  131. </DialogCom>
  132. </div>
  133. </template>
  134. <script>
  135. import { listArea, getArea, delArea, addArea, updateArea } from "@/api/system/area";
  136. export default {
  137. name: "Area",
  138. dicts:['sys_org_type'],
  139. data() {
  140. return {
  141. // 遮罩层
  142. loading: true,
  143. // 选中数组
  144. ids: [],
  145. names:[],
  146. // 非单个禁用
  147. single: true,
  148. // 非多个禁用
  149. multiple: true,
  150. // 显示搜索条件
  151. showSearch: true,
  152. // 总条数
  153. total: 0,
  154. // 【请填写功能名称】表格数据
  155. areaList: [],
  156. // 弹出层标题
  157. title: "",
  158. // 是否显示弹出层
  159. open: false,
  160. // 查询参数
  161. queryParams: {
  162. pageNum: 1,
  163. pageSize: 10,
  164. name: null,
  165. updateId: null,
  166. orgType: null
  167. },
  168. // 表单参数
  169. form: {},
  170. // 表单校验
  171. rules: {
  172. name: [
  173. { required: true, message: '请输入区域名称', trigger: 'blur' },
  174. ],
  175. orgType: [
  176. { required: true, message: '请选择机构类型', trigger: 'change' },
  177. ],
  178. }
  179. };
  180. },
  181. created() {
  182. this.getList();
  183. },
  184. methods: {
  185. /** 查询【请填写功能名称】列表 */
  186. getList() {
  187. this.loading = true;
  188. listArea(this.queryParams).then(response => {
  189. this.areaList = response.rows;
  190. this.total = response.total;
  191. this.loading = false;
  192. });
  193. },
  194. // 取消按钮
  195. cancel() {
  196. this.open = false;
  197. this.reset();
  198. },
  199. // 表单重置
  200. reset() {
  201. this.form = {
  202. id: null,
  203. name: null,
  204. createTime: null,
  205. updateBy: null,
  206. updateTime: null,
  207. updateId: null,
  208. delFlag: null,
  209. orgType: null
  210. };
  211. this.resetForm("form");
  212. },
  213. /** 搜索按钮操作 */
  214. handleQuery() {
  215. this.queryParams.pageNum = 1;
  216. this.getList();
  217. },
  218. /** 重置按钮操作 */
  219. resetQuery() {
  220. this.resetForm("queryForm");
  221. this.handleQuery();
  222. },
  223. // 多选框选中数据
  224. handleSelectionChange(selection) {
  225. this.ids = selection.map(item => item.id)
  226. this.names=selection.map(item => item.name)
  227. this.single = selection.length!==1
  228. this.multiple = !selection.length
  229. },
  230. /** 新增按钮操作 */
  231. handleAdd() {
  232. this.reset();
  233. this.open = true;
  234. this.title = "添加";
  235. },
  236. /** 修改按钮操作 */
  237. handleUpdate(row) {
  238. this.reset();
  239. const id = row.id || this.ids
  240. getArea(id).then(response => {
  241. this.form = response.data;
  242. this.open = true;
  243. this.title = "修改";
  244. });
  245. },
  246. /** 提交按钮 */
  247. submitForm() {
  248. this.$refs["form"].validate(valid => {
  249. if (valid) {
  250. if (this.form.id != null) {
  251. updateArea(this.form).then(response => {
  252. this.$modal.msgSuccess("修改成功");
  253. this.open = false;
  254. this.getList();
  255. });
  256. } else {
  257. addArea(this.form).then(response => {
  258. this.$modal.msgSuccess("新增成功");
  259. this.open = false;
  260. this.getList();
  261. });
  262. }
  263. }
  264. });
  265. },
  266. /** 删除按钮操作 */
  267. handleDelete(row) {
  268. const ids = row.id || this.ids;
  269. const names=row.name || this.names;
  270. this.$modal.confirm('是否确认删除区域名称为"' + names + '"的数据项?').then(function() {
  271. return delArea(ids);
  272. }).then(() => {
  273. this.getList();
  274. this.$modal.msgSuccess("删除成功");
  275. }).catch(() => {});
  276. },
  277. /** 导出按钮操作 */
  278. handleExport() {
  279. this.download('system/area/export', {
  280. ...this.queryParams
  281. }, `area_${new Date().getTime()}.xlsx`)
  282. }
  283. }
  284. };
  285. </script>