index.vue 8.5 KB

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