index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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="标题" label-width="40px">
  5. <el-input
  6. v-model="queryParams.title"
  7. placeholder="请输入标题"
  8. clearable
  9. style="width: 140px;"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="状态">
  14. <el-select
  15. v-model="queryParams.status"
  16. placeholder="状态"
  17. clearable
  18. style="width: 240px"
  19. >
  20. <el-option
  21. v-for="dict in statusList"
  22. :key="dict.value"
  23. :label="dict.name"
  24. :value="dict.value"
  25. />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="创建人">
  29. <el-input
  30. v-model="queryParams.createBy"
  31. placeholder="请输入创建人"
  32. clearable
  33. style="width: 140px;"
  34. @keyup.enter.native="handleQuery"
  35. />
  36. </el-form-item>
  37. <el-form-item>
  38. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  39. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  40. </el-form-item>
  41. </el-form>
  42. <el-row :gutter="10" class="mb8">
  43. <el-col :span="1.5">
  44. <el-button
  45. type="primary"
  46. plain
  47. icon="el-icon-plus"
  48. size="mini"
  49. @click="handleAdd"
  50. v-hasPermi="['informationMr:informationMr:add']"
  51. >添加资讯</el-button>
  52. </el-col>
  53. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  54. </el-row>
  55. <el-table ref="tables" v-loading="loading" :data="dataList" border>
  56. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  57. <el-table-column label="标题" align="center" prop="title" />
  58. <el-table-column label="封面图" align="center" prop="type">
  59. <template slot-scope="scope">
  60. <el-button type="text" @click="seeCenter(scope.row, 'img')">查看</el-button>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="内容" align="center" prop="type">
  64. <template slot-scope="scope">
  65. <el-button type="text" @click="seeCenter(scope.row, 'html')">查看</el-button>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="状态" align="center">
  69. <template slot-scope="scope">
  70. <el-tag type="success" v-if="scope.row.status == '1'">发布</el-tag>
  71. <el-tag type="danger" v-else-if="scope.row.status == '2'">下架</el-tag>
  72. <el-tag type="info" v-else>待发布</el-tag>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="发布时间" align="center" prop="onlineTime" width="160">
  76. <template slot-scope="scope">
  77. <span>{{ parseTime(scope.row.onlineTime) }}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="浏览量" align="center" prop="browseNum" />
  81. <el-table-column label="创建时间" align="center" prop="createTime" width="160">
  82. <template slot-scope="scope">
  83. <span>{{ parseTime(scope.row.createTime) }}</span>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="创建人" align="center" prop="createBy" />
  87. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  88. <template slot-scope="scope">
  89. <el-button
  90. size="mini"
  91. type="text"
  92. @click="ionlineApi(scope.row)"
  93. v-hasPermi="['informationMr:informationMr:release']"
  94. >{{scope.row.status == '1' ? '取消发布' : '发布'}}</el-button>
  95. <el-button
  96. size="mini"
  97. type="text"
  98. v-if="scope.row.status != '1'"
  99. @click="handleUpdate(scope.row)"
  100. v-hasPermi="['informationMr:informationMr:edit']"
  101. >修改</el-button>
  102. <el-button
  103. size="mini"
  104. type="text"
  105. v-if="scope.row.status != '1'"
  106. @click="handleDelete(scope.row,scope.index)"
  107. v-hasPermi="['informationMr:informationMr:delete']"
  108. >删除</el-button>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. <pagination
  113. v-show="total>0"
  114. :total="total"
  115. :page.sync="queryParams.pageNum"
  116. :limit.sync="queryParams.pageSize"
  117. @pagination="getList"
  118. />
  119. <!-- 新增/编辑弹框 -->
  120. <add-and-edit
  121. ref="addAndEdit"
  122. :dict="dict"
  123. @getList="getList"
  124. />
  125. <el-dialog
  126. title="查看"
  127. :visible.sync="visibleStatus"
  128. width="600px"
  129. :destroy-on-close="true"
  130. :close-on-click-modal="false"
  131. >
  132. <div v-if="visibleType == 'img'">
  133. <el-image
  134. style="width: 400px; height: 100%"
  135. :src="newObj.mainImg"
  136. fit="cover"
  137. />
  138. </div>
  139. <div v-if="visibleType == 'html'">
  140. <div v-html="newObj.centent"></div>
  141. </div>
  142. <div slot="footer" class="dialog-footer">
  143. <el-button type="primary" @click="visibleStatus = false">确 定</el-button>
  144. </div>
  145. </el-dialog>
  146. </div>
  147. </template>
  148. <script>
  149. import { pageList, deleteById, ionline } from '@/api/perform/perform'
  150. import addAndEdit from "./dialog/addAndEdit.vue";
  151. export default {
  152. name: "agreement",
  153. dicts: ['agreement_type'],
  154. components: { addAndEdit },
  155. data() {
  156. return {
  157. // 遮罩层
  158. loading: true,
  159. // 选中数组
  160. ids: [],
  161. // 非单个禁用
  162. single: true,
  163. // 非多个禁用
  164. multiple: true,
  165. // 显示搜索条件
  166. showSearch: true,
  167. // 总条数
  168. total: 0,
  169. // 用户表格数据
  170. dataList: null,
  171. // 弹出层标题
  172. title: "",
  173. // 是否显示弹出层
  174. open: false,
  175. // 日期范围
  176. dateRange: [],
  177. // 查询参数
  178. queryParams: {
  179. pageNum: 1,
  180. pageSize: 10,
  181. type: undefined
  182. },
  183. statusList: [
  184. {id: 1, name: '未发布', value: 0},
  185. {id: 2, name: '发布', value: 1},
  186. {id: 3, name: '下架', value: 2},
  187. ],
  188. visibleStatus: false,
  189. newObj: {},
  190. visibleType: ''
  191. };
  192. },
  193. created() {
  194. this.getList();
  195. },
  196. methods: {
  197. /** 查询列表 */
  198. getList() {
  199. this.loading = true;
  200. pageList(this.addDateRange(this.queryParams, this.dateRange))
  201. .then(response => {
  202. this.dataList = response.data.rows;
  203. this.total = response.data.total;
  204. this.loading = false;
  205. }
  206. );
  207. },
  208. // 取消按钮
  209. cancel() {
  210. this.open = false;
  211. },
  212. /** 搜索按钮操作 */
  213. handleQuery() {
  214. this.queryParams.pageNum = 1;
  215. this.getList();
  216. },
  217. /** 重置按钮操作 */
  218. resetQuery() {
  219. this.dateRange = [];
  220. this.$set(this.queryParams, 'title', '');
  221. this.$set(this.queryParams, 'status', '');
  222. this.$set(this.queryParams, 'createBy', '');
  223. this.queryParams.pageNum = 1;
  224. this.handleQuery();
  225. },
  226. // 多选框选中数据
  227. handleSelectionChange(selection) {
  228. this.ids = selection.map(item => item.userId);
  229. this.single = selection.length != 1;
  230. this.multiple = !selection.length;
  231. },
  232. /** 新增按钮操作 */
  233. handleAdd() {
  234. this.$refs["addAndEdit"].openDialog("新增数据", null);
  235. },
  236. /** 修改按钮操作 */
  237. handleUpdate(row) {
  238. this.$refs["addAndEdit"].openDialog("修改数据", row);
  239. },
  240. /** 发布或者取消发布按钮操作 */
  241. ionlineApi(row) {
  242. this.$confirm("是否对标题为" + row.title + "的数据进行" + (row.status == 1 ? '下架?' : '发布?'), '提示', {
  243. confirmButtonText: '确定',
  244. cancelButtonText: '取消',
  245. type: 'warning'
  246. }).then(() => {
  247. ionline({ id: row.id, status: row.status == 1 ? 2 : 1 }).then((res) => {
  248. if (res.code == 200) {
  249. this.$message({
  250. type: 'success',
  251. message: '操作成功!'
  252. });
  253. this.getList();
  254. }
  255. });
  256. }).catch(() => {});
  257. },
  258. /** 删除按钮操作 */
  259. handleDelete(row) {
  260. this.$modal.confirm('是否确认删除数据标题为"' + row.title + '"的数据项?').then(function() {
  261. return deleteById(row.id);
  262. }).then(() => {
  263. this.getList();
  264. this.$modal.msgSuccess("删除成功");
  265. }).catch(() => {});
  266. },
  267. /** 查看按钮操作 */
  268. seeCenter(obj, type) {
  269. this.visibleStatus = true
  270. this.visibleType = type;
  271. this.newObj = obj;
  272. }
  273. }
  274. };
  275. </script>