index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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. <template slot-scope="scope">
  70. <span>{{scope.$index + 1 + (queryParams.pageNum-1) * queryParams.pageSize}}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="标题" align="center" prop="titleName"/>
  74. <!--<el-table-column label="正文" align="center" prop="textDetails"/>-->
  75. <el-table-column label="图片" align="center" prop="imgUrl" width="100">
  76. <template slot-scope="scope">
  77. <image-preview :src="scope.row.imgUrlList" :width="50" :height="50"/>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  81. <template slot-scope="scope">
  82. <el-button
  83. size="mini"
  84. type="text"
  85. icon="el-icon-edit"
  86. @click="handleUpdate(scope.row)"
  87. v-hasPermi="['system:server:edit']"
  88. >修改
  89. </el-button>
  90. <el-button
  91. size="mini"
  92. type="text"
  93. icon="el-icon-view"
  94. @click="handleView(scope.row)"
  95. v-hasPermi="['system:server:edit']"
  96. >详情</el-button>
  97. <el-button
  98. size="mini"
  99. type="text"
  100. icon="el-icon-delete"
  101. @click="handleDelete(scope.row)"
  102. v-hasPermi="['system:server:remove']"
  103. >删除
  104. </el-button>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <pagination
  109. v-show="total>0"
  110. :total="total"
  111. :page.sync="queryParams.pageNum"
  112. :limit.sync="queryParams.pageSize"
  113. @pagination="getList"
  114. />
  115. <!-- 添加或修改乡村婚恋对话框 -->
  116. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  117. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  118. <el-form-item label="标题" prop="titleName">
  119. <el-input v-model="form.titleName" placeholder="请输入标题" maxLength="20" :readonly="view"/>
  120. </el-form-item>
  121. <el-form-item label="正文" prop="textDetails">
  122. <editor v-model="form.textDetails" :min-height="192" v-if="open" :readOnly="view"/>
  123. </el-form-item>
  124. <el-form-item label="图片" prop="imgUrlList">
  125. <image-preview :src="form.imgUrlList" v-if="view" />
  126. <image-upload v-model="form.imgUrlList" v-else />
  127. </el-form-item>
  128. </el-form>
  129. <div slot="footer" class="dialog-footer">
  130. <el-button type="primary" @click="submitForm" v-if="!view">确 定</el-button>
  131. <el-button @click="cancel" v-if="!view">取 消</el-button>
  132. <el-button @click="cancel" v-if="view">关 闭</el-button>
  133. </div>
  134. </el-dialog>
  135. </div>
  136. </template>
  137. <script>
  138. import {listServer, getServer, delServer, addServer, updateServer} from "@/api/highServer/highServer";
  139. export default {
  140. name: "Server",
  141. data() {
  142. return {
  143. // 遮罩层
  144. loading: true,
  145. // 选中数组
  146. ids: [],
  147. // 选中名称数组
  148. names: [],
  149. // 详情只读
  150. view: false,
  151. // 非单个禁用
  152. single: true,
  153. // 非多个禁用
  154. multiple: true,
  155. // 显示搜索条件
  156. showSearch: true,
  157. // 总条数
  158. total: 0,
  159. // 乡村婚恋表格数据
  160. serverList: [],
  161. // 弹出层标题
  162. title: "",
  163. // 是否显示弹出层
  164. open: false,
  165. // 查询参数
  166. queryParams: {
  167. pageNum: 1,
  168. pageSize: 10,
  169. titleName: null,
  170. textDetails: null,
  171. type: null,
  172. },
  173. // 表单参数
  174. form: {},
  175. // 表单校验
  176. rules: {
  177. titleName: [
  178. {required: true, message: "标题不能为空", trigger: "blur"},
  179. ],
  180. textDetails: [
  181. {required: true, message: "正文不能为空", trigger: "blur"},
  182. ],
  183. }
  184. };
  185. },
  186. created() {
  187. this.queryParams.type = this.$route.query.type;
  188. this.getList();
  189. },
  190. methods: {
  191. /** 查询乡村婚恋列表 */
  192. getList() {
  193. this.loading = true;
  194. listServer(this.queryParams).then(response => {
  195. this.serverList = response.rows;
  196. this.total = response.total;
  197. this.loading = false;
  198. });
  199. },
  200. // 取消按钮
  201. cancel() {
  202. this.open = false;
  203. this.reset();
  204. },
  205. // 表单重置
  206. reset() {
  207. this.view = false;
  208. this.form = {
  209. id: null,
  210. titleName: null,
  211. textDetails: null,
  212. type: this.$route.query.type,
  213. createBy: null,
  214. createTime: null,
  215. updateBy: null,
  216. updateTime: null,
  217. imgUrlList: null,
  218. };
  219. this.resetForm("form");
  220. },
  221. /** 搜索按钮操作 */
  222. handleQuery() {
  223. this.queryParams.pageNum = 1;
  224. this.getList();
  225. },
  226. /** 重置按钮操作 */
  227. resetQuery() {
  228. this.resetForm("queryForm");
  229. this.handleQuery();
  230. },
  231. // 多选框选中数据
  232. handleSelectionChange(selection) {
  233. this.ids = selection.map(item => item.id)
  234. this.names = selection.map(item => item.titleName);
  235. this.single = selection.length !== 1
  236. this.multiple = !selection.length
  237. },
  238. /** 新增按钮操作 */
  239. handleAdd() {
  240. this.reset();
  241. this.open = true;
  242. this.title = "添加乡村婚恋";
  243. },
  244. /** 修改按钮操作 */
  245. handleUpdate(row) {
  246. this.reset();
  247. const id = row.id || this.ids
  248. getServer(id).then(response => {
  249. this.form = response.data;
  250. this.open = true;
  251. this.title = "修改乡村婚恋";
  252. });
  253. },
  254. /** 详情按钮操作 */
  255. handleView(row) {
  256. this.reset();
  257. this.view = true; // 开启详情只读
  258. const id = row.id || this.ids
  259. getServer(id).then(response => {
  260. this.form = response.data;
  261. this.open = true;
  262. this.title = "乡村婚恋详情";
  263. });
  264. },
  265. /** 提交按钮 */
  266. submitForm() {
  267. this.$refs["form"].validate(valid => {
  268. if (valid) {
  269. if (this.form.id != null) {
  270. updateServer(this.form).then(response => {
  271. this.$modal.msgSuccess("修改成功");
  272. this.open = false;
  273. this.getList();
  274. });
  275. } else {
  276. addServer(this.form).then(response => {
  277. this.$modal.msgSuccess("新增成功");
  278. this.open = false;
  279. this.getList();
  280. });
  281. }
  282. }
  283. });
  284. },
  285. /** 删除按钮操作 */
  286. handleDelete(row) {
  287. const ids = row.id || this.ids;
  288. const names = row.titleName || this.names;
  289. this.$modal.confirm('是否确认删除乡村婚恋名称为"' + names + '"的数据项?').then(function() {
  290. return delServer(ids);
  291. }).then(() => {
  292. this.getList();
  293. this.$modal.msgSuccess("删除成功");
  294. }).catch(() => {});
  295. },
  296. /** 导出按钮操作 */
  297. handleExport() {
  298. this.download('high/server/export', {
  299. ...this.queryParams
  300. }, `server_${new Date().getTime()}.xlsx`)
  301. }
  302. }
  303. };
  304. </script>