You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

377 lines
9.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <div style="padding:30px;">
  3. <!-- 搜索栏 -->
  4. <div class="search">
  5. <el-form :inline="true">
  6. <el-form-item label="剧本标题:" style="margin-right:50px;">
  7. <el-select
  8. v-model="queryParams.query.scenarioId"
  9. clearable
  10. placeholder="请选择剧本标题"
  11. >
  12. <el-option
  13. v-for="item in jbData"
  14. :key="item.value"
  15. :label="item.title"
  16. :value="item.id"
  17. >
  18. </el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="流程标题:" style="margin-right:50px;">
  22. <el-select
  23. v-model="queryParams.query.processId"
  24. clearable
  25. placeholder="请选择流程标题"
  26. >
  27. <el-option
  28. v-for="item in lcData"
  29. :key="item.value"
  30. :label="item.title"
  31. :value="item.id"
  32. >
  33. </el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="Tips内容:" style="margin-right:50px;">
  37. <el-input
  38. clearable
  39. v-model="queryParams.query.content"
  40. placeholder="Tips内容"
  41. />
  42. </el-form-item>
  43. </el-form>
  44. <div class="search-button">
  45. <el-button
  46. size="medium"
  47. type="primary"
  48. style="height:36px;width:100px;"
  49. @click="search"
  50. >搜索</el-button
  51. >
  52. <el-button
  53. size="medium"
  54. style="margin-left:20px;height:36px;width:100px;"
  55. @click="refresh"
  56. >重置</el-button
  57. >
  58. </div>
  59. </div>
  60. <div class="add-button">
  61. <el-button
  62. size="medium"
  63. type="primary"
  64. style="height:36px;width:100px;"
  65. @click="handleAdd"
  66. >新建</el-button
  67. >
  68. </div>
  69. <!-- 列表 -->
  70. <div class="content">
  71. <el-table
  72. v-loading="loading"
  73. ref="singleTable"
  74. :data="tableData"
  75. border
  76. style="width: 100%"
  77. >
  78. <el-table-column align="center" type="index" label="序号" width="50" />
  79. <el-table-column
  80. align="center"
  81. property="scenarioTitle"
  82. label="剧本标题"
  83. />
  84. <el-table-column
  85. align="center"
  86. property="processTitle"
  87. label="流程名称"
  88. />
  89. <el-table-column align="center" property="content" label="Tips内容" />
  90. <el-table-column align="center" property="likeCount" label="点赞数量" />
  91. <el-table-column
  92. align="center"
  93. property="createTime"
  94. label="创建时间"
  95. />
  96. <el-table-column align="center" label="操作">
  97. <template slot-scope="scope">
  98. <el-button type="text" size="mini" @click="handleView(scope.row)"
  99. ><div style="color:#000;">查看</div></el-button
  100. >
  101. <el-button type="text" size="mini" @click="handleEdit(scope.row)"
  102. ><div style="color:#02A7F0;">编辑</div></el-button
  103. >
  104. <el-button type="text" size="mini" @click="hanDel(scope.row)"
  105. ><div style="color:#D9001B;">删除</div></el-button
  106. >
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <pagination
  111. v-show="total > 0"
  112. :total="total"
  113. :page.sync="queryParams.pageNum"
  114. :limit.sync="queryParams.pageSize"
  115. @pagination="queryTipsList"
  116. />
  117. </div>
  118. <!-- 新增表单 -->
  119. <el-dialog
  120. :title="dialog.title"
  121. :visible.sync="dialog.Visible"
  122. center
  123. width="35%"
  124. >
  125. <el-form ref="form" :model="form" :inline="true">
  126. <el-form-item label="剧本标题:" prop="name" style="width:100%">
  127. <el-select
  128. :disabled="disabled"
  129. v-model="form.scenarioId"
  130. clearable
  131. placeholder="请选择剧本标题"
  132. style="width:300px"
  133. >
  134. <el-option
  135. v-for="item in jbData"
  136. :key="item.value"
  137. :label="item.title"
  138. :value="item.id"
  139. >
  140. </el-option>
  141. </el-select>
  142. </el-form-item>
  143. <el-form-item label="流程标题:" style="width:100%">
  144. <el-select
  145. :disabled="disabled"
  146. v-model="form.processId"
  147. clearable
  148. placeholder="请选择活动区域"
  149. style="width:300px"
  150. >
  151. <el-option
  152. v-for="item in lcData"
  153. :key="item.value"
  154. :label="item.title"
  155. :value="item.id"
  156. />
  157. </el-select>
  158. </el-form-item>
  159. <el-form-item label="Tips内容:" style="width:100%">
  160. <el-input
  161. :disabled="disabled"
  162. style="width:300px"
  163. v-model="form.content"
  164. type="textarea"
  165. :rows="6"
  166. placeholder="请输入内容"
  167. autocomplete="off"
  168. ></el-input>
  169. </el-form-item>
  170. </el-form>
  171. <div slot="footer" class="dialog-footer">
  172. <el-button @click="dialog.Visible = false"> </el-button>
  173. <el-button v-if="type != 'view'" type="primary" @click="subMitForm()"> </el-button>
  174. </div>
  175. </el-dialog>
  176. </div>
  177. </template>
  178. <script>
  179. import {
  180. queryJbInfos,
  181. queryTipsList,
  182. addTipsList,
  183. updateTipsList,
  184. deteleTipsList,
  185. queryTipsDetail,
  186. queryFindList
  187. } from "@/api/userInfoApi.js";
  188. export default {
  189. data() {
  190. return {
  191. loading: true,
  192. queryParams: {
  193. pageNum: 1,
  194. pageSize: 15,
  195. query: {
  196. scenarioId: undefined,
  197. processId: undefined,
  198. content: undefined
  199. }
  200. },
  201. form: {},
  202. disabled: false,
  203. dialog: {
  204. title: "新增",
  205. Visible: false
  206. },
  207. tableData: [],
  208. jbData: [],
  209. lcData: [],
  210. total: 0,
  211. type: "add"
  212. };
  213. },
  214. mounted() {
  215. this.queryJbInfos();
  216. this.queryFindList();
  217. this.queryTipsList();
  218. },
  219. methods: {
  220. //获取剧本列表
  221. async queryJbInfos() {
  222. try {
  223. let res = await queryJbInfos({});
  224. // console.log(res.data, "剧本列表");
  225. this.jbData = res.data;
  226. } catch (err) {
  227. console.log(err);
  228. }
  229. },
  230. //获取流程列表
  231. async queryFindList() {
  232. try {
  233. let res = await queryFindList({});
  234. // console.log(res.data, "流程列表");
  235. this.lcData = res.data;
  236. } catch (err) {
  237. console.log(err);
  238. }
  239. },
  240. //获取Tips列表
  241. async queryTipsList() {
  242. this.loading = true;
  243. try {
  244. let res = await queryTipsList(this.queryParams);
  245. this.tableData = res.data.rows;
  246. this.total = res.data.total;
  247. this.loading = false;
  248. } catch (err) {
  249. console.log(err);
  250. }
  251. },
  252. //搜索
  253. search() {
  254. this.queryTipsList();
  255. },
  256. refresh() {
  257. this.queryParams = {
  258. pageNum: 1,
  259. pageSize: 15,
  260. query: {
  261. scenarioId: undefined,
  262. processId: undefined,
  263. content: undefined
  264. }
  265. };
  266. this.queryTipsList();
  267. },
  268. // 新增
  269. handleAdd() {
  270. this.dialog.title = "新增";
  271. this.type = 'add'
  272. this.form = {}
  273. this.disabled = false;
  274. this.dialog.Visible = true;
  275. },
  276. //提交表单
  277. async subMitForm() {
  278. try {
  279. this.$refs["form"].validate(async valid => {
  280. if (valid) {
  281. if (this.type == "add") {
  282. let res = await addTipsList(this.form);
  283. if (res.code == 200) {
  284. this.$message.success("新增成功");
  285. this.dialog.Visible = false;
  286. this.form = {};
  287. this.queryTipsList();
  288. } else {
  289. this.$message({
  290. message: res.msg,
  291. type: "error"
  292. });
  293. }
  294. }
  295. if(this.type == 'edit'){
  296. let res = await updateTipsList(this.form);
  297. if (res.code == 200) {
  298. this.$message.success("编辑成功");
  299. this.dialog.Visible = false;
  300. this.form = {};
  301. this.queryTipsList();
  302. } else {
  303. this.$message({
  304. message: res.msg,
  305. type: "error"
  306. });
  307. }
  308. }
  309. }
  310. });
  311. } catch (err) {
  312. console.log(err);
  313. }
  314. },
  315. //获取详情
  316. async queryTipsDetail(id) {
  317. try {
  318. let res = await queryTipsDetail(id);
  319. // console.log(res, "详情");
  320. this.form = res.data;
  321. } catch (err) {
  322. console.log(err);
  323. }
  324. },
  325. //查看详情
  326. handleView(row) {
  327. this.queryTipsDetail(row.id);
  328. this.dialog.title = "查看";
  329. this.type = "view";
  330. this.disabled = true;
  331. this.dialog.Visible = true;
  332. },
  333. //编辑
  334. handleEdit(row) {
  335. this.queryTipsDetail(row.id);
  336. this.dialog.title = "编辑";
  337. this.type = "edit";
  338. this.disabled = false;
  339. this.dialog.Visible = true;
  340. },
  341. //删除
  342. async hanDel(row) {
  343. try {
  344. await this.$confirm("此操作将永久删除,是否继续?", "提示", {
  345. confirmButtonText: "确定",
  346. cancelButtonText: "取消",
  347. type: "warning"
  348. });
  349. let res = await deteleTipsList(row.id);
  350. if (res.code == 200) {
  351. this.$message.success("删除成功");
  352. this.queryList();
  353. } else {
  354. this.$message({
  355. message: res.msg,
  356. type: "error"
  357. });
  358. }
  359. } catch (err) {
  360. console.log(err);
  361. }
  362. }
  363. }
  364. };
  365. </script>
  366. <style scoped>
  367. .content {
  368. background: #fff;
  369. margin-top: 15px;
  370. }
  371. .add-button {
  372. margin-top: 15px;
  373. }
  374. .search-button {
  375. display: flex;
  376. }
  377. </style>