index.vue 7.7 KB

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