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.

547 lines
15 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
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
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
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="剧本标题" prop="leaderId">
  7. <el-select filterable remote reserve-keyword
  8. @change="queryLc"
  9. v-model="queryParams.query.scenarioId"
  10. placeholder="请输入剧本标题"
  11. @focus.once="queryLcAll"
  12. :remote-method="remoteMethod"
  13. :loading="loading">
  14. <el-option v-for="item in jbData" :key="item.id" :label="item.title" :value="item.id"></el-option>
  15. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :pager-count="5" :current-page.sync="currentPage"
  16. :page-size="pagesize" layout="total, prev, pager, next" :total="totalnum">
  17. </el-pagination>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="流程标题:" style="margin-right:50px;">
  21. <el-select v-model="queryParams.query.processCode" clearable placeholder="请选择流程标题">
  22. <el-option v-for="item in lcData" :key="item.value" :label="item.title" :value="item.code"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="Tips内容:" style="margin-right:50px;">
  26. <el-input
  27. clearable
  28. v-model="queryParams.query.content"
  29. placeholder="Tips内容"
  30. />
  31. </el-form-item>
  32. </el-form>
  33. <div class="search-button">
  34. <el-button
  35. size="medium"
  36. type="primary"
  37. style="height:36px;width:100px;"
  38. @click="search"
  39. >搜索</el-button
  40. >
  41. <el-button
  42. size="medium"
  43. style="margin-left:20px;height:36px;width:100px;"
  44. @click="refresh"
  45. >重置</el-button
  46. >
  47. </div>
  48. </div>
  49. <div class="add-button">
  50. <el-button
  51. size="medium"
  52. type="primary"
  53. style="height:36px;width:100px;"
  54. @click="handleAdd"
  55. >新建</el-button
  56. >
  57. </div>
  58. <!-- 列表 -->
  59. <div class="content">
  60. <el-table
  61. v-loading="loading"
  62. ref="singleTable"
  63. :data="tableData"
  64. border
  65. style="width: 100%"
  66. >
  67. <el-table-column align="center" type="index" label="序号" width="50" />
  68. <el-table-column
  69. align="center"
  70. property="scenarioTitle"
  71. label="剧本标题"
  72. />
  73. <el-table-column
  74. align="center"
  75. property="processTitle"
  76. label="流程名称"
  77. />
  78. <el-table-column align="center" property="content" label="Tips内容" />
  79. <el-table-column align="center" property="likeCount" label="点赞数量" />
  80. <el-table-column
  81. align="center"
  82. property="createTime"
  83. label="创建时间"
  84. />
  85. <el-table-column align="center" label="操作">
  86. <template slot-scope="scope">
  87. <el-button type="text" size="mini" @click="handleView(scope.row)"
  88. ><div style="color:#000;">查看</div></el-button
  89. >
  90. <el-button type="text" size="mini" @click="handleEdit(scope.row)"
  91. ><div style="color:#02A7F0;">编辑</div></el-button
  92. >
  93. <el-button type="text" size="mini" @click="hanDel(scope.row)"
  94. ><div style="color:#D9001B;">删除</div></el-button
  95. >
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="queryTipsList" />
  100. </div>
  101. <!-- 新增表单 -->
  102. <el-dialog
  103. :title="dialog.title"
  104. :visible.sync="dialog.Visible"
  105. center
  106. width="500px"
  107. >
  108. <el-form ref="form" :model="form" :inline="true" :rules="rules">
  109. <!-- <el-form-item label="剧本标题:" prop="scenarioId" style="width:100%">
  110. <el-select
  111. :disabled="disabled"
  112. v-model="form.scenarioId"
  113. clearable
  114. placeholder="请选择剧本标题"
  115. style="width:300px"
  116. @change="chageLc"
  117. >
  118. <el-option
  119. v-for="item in jbData"
  120. :key="item.value"
  121. :label="item.title"
  122. :value="item.id"
  123. >
  124. </el-option>
  125. </el-select>
  126. </el-form-item> -->
  127. <el-form-item label="剧本标题:" style="width:100%" prop="scenarioId">
  128. <el-select filterable remote reserve-keyword
  129. @change="queryLcAdd"
  130. v-model="form.scenarioId"
  131. placeholder="请输入剧本标题"
  132. style="width:300px"
  133. @focus.once="queryLcAllAdd"
  134. :remote-method="remoteMethodAdd"
  135. :loading="loading">
  136. <el-option v-for="item in jbData" :key="item.id" :label="item.title" :value="item.id"></el-option>
  137. <el-pagination @size-change="handleSizeChangeAdd" @current-change="handleCurrentChangeAdd" :pager-count="5" :current-page.sync="currentPage"
  138. :page-size="pagesize" layout="total, prev, pager, next" :total="totalnum">
  139. </el-pagination>
  140. </el-select>
  141. </el-form-item>
  142. <el-form-item label="流程标题:" style="width:100%" prop="processId">
  143. {{form.processCode}}
  144. <el-select
  145. :disabled="disabled"
  146. v-model="form.processCode"
  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.code"
  156. />
  157. </el-select>
  158. </el-form-item>
  159. <el-form-item label="Tips内容:" style="width:100%" prop="content">
  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="cancelMitForm"> </el-button>
  173. <el-button v-if="type != 'view'" type="primary" @click="subMitForm()"
  174. > </el-button
  175. >
  176. </div>
  177. </el-dialog>
  178. </div>
  179. </template>
  180. <script>
  181. import {
  182. queryJbInfo,
  183. queryJbInfos,
  184. queryTipsList,
  185. addTipsList,
  186. updateTipsList,
  187. deteleTipsList,
  188. queryTipsDetail,
  189. queryFindList
  190. } from "@/api/sce/sce.js";
  191. export default {
  192. data() {
  193. return {
  194. loading: true,
  195. currentPage: 1,
  196. pagesize: 10,
  197. totalnum: 0,
  198. title:"",
  199. queryParams: {
  200. pageNum: 1,
  201. pageSize: 10,
  202. query: {
  203. scenarioId: undefined,
  204. processCode: undefined,
  205. content: undefined
  206. }
  207. },
  208. rules: {
  209. scenarioId: [
  210. { required: true, message: "请选择剧本", trigger: "blur" }
  211. ],
  212. processCode: [{ required: true, message: "请选择流程", trigger: "blur" }],
  213. content: [{ required: true, message: "请输入内容", trigger: "blur" }]
  214. },
  215. form: {},
  216. disabled: false,
  217. dialog: {
  218. title: "新增",
  219. Visible: false
  220. },
  221. tableData: [],
  222. jbData: [],
  223. jbDataAll: [],
  224. lcData: [],
  225. total: 0,
  226. type: "add",
  227. data: {}
  228. };
  229. },
  230. mounted() {
  231. // this.queryJbInfos();
  232. // this.queryFindList();
  233. this.queryTipsList();
  234. },
  235. methods: {
  236. //获取剧本列表
  237. // async queryJbInfos() {
  238. // try {
  239. // let res = await queryJbInfos({});
  240. // this.jbData = res.data;
  241. // } catch (err) {
  242. // }
  243. // },
  244. //鼠标获取焦点触发
  245. queryLcAll(){
  246. this.remoteMethod('');
  247. },
  248. //鼠标获取焦点触发
  249. queryLcAllAdd(){
  250. this.remoteMethodAdd('');
  251. },
  252. remoteMethod(e) {
  253. this.title = e;
  254. if( this.queryParams.query.scenarioId != this.title){
  255. this.currentPage = 1;//页码
  256. console.log(this.currentPage);
  257. }
  258. queryJbInfo({
  259. pageSize: this.pagesize,
  260. pageNum: this.currentPage,
  261. query: {
  262. title: this.title,
  263. },
  264. }).then((res) => {
  265. if (res.code == 200) {
  266. var arr = [];
  267. arr = res.data.rows.map((item) => {
  268. return {
  269. value: item.id,
  270. title: item.title,
  271. id : item.id
  272. };
  273. });
  274. this.jbData = arr;
  275. this.totalnum = parseInt(res.data.total);
  276. }
  277. });
  278. },
  279. remoteMethodAdd(e) {
  280. this.title = e;
  281. if( this.form.scenarioId != this.title){
  282. this.currentPage = 1;//页码
  283. console.log(this.currentPage);
  284. }
  285. queryJbInfo({
  286. pageSize: this.pagesize,
  287. pageNum: this.currentPage,
  288. query: {
  289. title: this.title,
  290. },
  291. }).then((res) => {
  292. if (res.code == 200) {
  293. var arr = [];
  294. arr = res.data.rows.map((item) => {
  295. return {
  296. value: item.id,
  297. title: item.title,
  298. id : item.id
  299. };
  300. });
  301. this.jbData = arr;
  302. this.totalnum = parseInt(res.data.total);
  303. }
  304. });
  305. },
  306. handleSizeChange(val) {
  307. this.pagesize = val;
  308. this.queryParams.query.scenarioId = this.title;
  309. if( this.queryParams.query.scenarioId != this.title){
  310. this.currentPage = 1;//页码
  311. console.log(this.currentPage);
  312. }
  313. this.remoteMethod(this.title);
  314. },
  315. handleSizeChangeAdd(val) {
  316. this.pagesize = val;
  317. this.form.scenarioId = this.title;
  318. if( this.form.scenarioId != this.title){
  319. this.currentPage = 1;//页码
  320. console.log(this.currentPage);
  321. }
  322. this.remoteMethodAdd(this.title);
  323. },
  324. handleCurrentChange(val) {
  325. this.currentPage = val;
  326. this.queryParams.query.scenarioId = this.title;
  327. this.remoteMethod(this.title);
  328. },
  329. handleCurrentChangeAdd(val) {
  330. this.currentPage = val;
  331. this.form.scenarioId = this.title;
  332. this.remoteMethodAdd(this.title);
  333. },
  334. //获取流程列表
  335. async queryFindList() {
  336. try {
  337. let res = await queryFindList(this.data);
  338. this.lcData = res.data;
  339. } catch (err) {
  340. }
  341. },
  342. queryLc(val) {
  343. this.data = {
  344. scenarioId: val
  345. };
  346. delete this.queryParams.query.processId;
  347. this.queryFindList();
  348. this.$router.push({ name: "Tips/index" });
  349. },
  350. queryLcAdd(val) {
  351. this.data = {
  352. scenarioId: val
  353. };
  354. delete this.form.processId;
  355. this.queryFindList();
  356. this.$router.push({ name: "Tips/index" });
  357. },
  358. chageLc(val) {
  359. this.data = {
  360. scenarioId: val
  361. };
  362. delete this.form.processId;
  363. // this.form.processId =
  364. this.queryFindList();
  365. },
  366. foucsLc() {
  367. },
  368. //获取Tips列表
  369. async queryTipsList() {
  370. this.loading = true;
  371. if (this.$route.query.type == "sceinfo") {
  372. this.remoteMethod(''); //调用所有剧本标题数据
  373. let res = await queryTipsList(this.queryParams);
  374. this.jbData.forEach(item=>{
  375. if(item.id == this.$route.query.scenarioId){
  376. this.queryParams.query.scenarioId = this.$route.query.scenarioId
  377. this.data = {
  378. scenarioId: this.$route.query.scenarioId
  379. };
  380. this.queryFindList();
  381. }
  382. })
  383. }
  384. try {
  385. let res = await queryTipsList(this.queryParams);
  386. this.tableData = res.data.rows;
  387. this.total = res.data.total;
  388. this.loading = false;
  389. } catch (err) {
  390. }
  391. },
  392. //搜索
  393. search() {
  394. this.queryTipsList();
  395. },
  396. refresh() {
  397. this.$router.push({ name: "Tips/index" });
  398. this.remoteMethod('');//重置剧本标题搜索
  399. this.queryParams = {
  400. pageNum: 1,
  401. pageSize: 10,
  402. query: {
  403. scenarioId: undefined,
  404. processId: undefined,
  405. content: undefined
  406. }
  407. };
  408. this.data = {};
  409. // this.queryFindList();
  410. this.queryTipsList();
  411. },
  412. // 新增
  413. handleAdd() {
  414. this.dialog.title = "新增";
  415. this.type = "add";
  416. this.form = {};
  417. this.lcData = []
  418. this.disabled = false;
  419. this.dialog.Visible = true;
  420. },
  421. //取消表单
  422. cancelMitForm(){
  423. this.remoteMethodAdd('');//重置剧本标题内容
  424. console.log('123');
  425. this.dialog.Visible = false
  426. },
  427. //提交表单
  428. async subMitForm() {
  429. try {
  430. this.cancelMitForm();//取消表单弹窗
  431. this.$refs["form"].validate(async valid => {
  432. if (valid) {
  433. if (this.type == "add") {
  434. let res = await addTipsList(this.form);
  435. if (res.code == 200) {
  436. this.$message.success("新增成功");
  437. this.dialog.Visible = false;
  438. this.form = {};
  439. this.queryTipsList();
  440. } else {
  441. this.$message({
  442. message: res.msg,
  443. type: "error"
  444. });
  445. }
  446. }
  447. if (this.type == "edit") {
  448. let res = await updateTipsList(this.form);
  449. if (res.code == 200) {
  450. this.$message.success("编辑成功");
  451. this.dialog.Visible = false;
  452. this.form = {};
  453. this.queryTipsList();
  454. } else {
  455. this.$message({
  456. message: res.msg,
  457. type: "error"
  458. });
  459. }
  460. }
  461. }
  462. });
  463. } catch (err) {
  464. }
  465. },
  466. //获取详情
  467. async queryTipsDetail(id) {
  468. try {
  469. let res = await queryTipsDetail(id);
  470. this.form = res.data;
  471. } catch (err) {
  472. }
  473. },
  474. //查看详情
  475. handleView(row) {
  476. this.queryTipsDetail(row.id);
  477. this.data = {
  478. scenarioId: row.scenarioId
  479. };
  480. this.queryFindList();
  481. setTimeout(() => {
  482. this.dialog.title = "查看";
  483. this.type = "view";
  484. this.disabled = true;
  485. this.dialog.Visible = true;
  486. }, 500);
  487. },
  488. //编辑
  489. handleEdit(row) {
  490. this.queryTipsDetail(row.id);
  491. this.data = {
  492. scenarioId: row.scenarioId
  493. };
  494. this.queryFindList();
  495. setTimeout(() => {
  496. this.dialog.title = "编辑";
  497. this.type = "edit";
  498. this.disabled = false;
  499. this.dialog.Visible = true;
  500. }, 500);
  501. },
  502. //删除
  503. async hanDel(row) {
  504. try {
  505. await this.$confirm("此操作将永久删除,是否继续?", "提示", {
  506. confirmButtonText: "确定",
  507. cancelButtonText: "取消",
  508. type: "warning"
  509. });
  510. let res = await deteleTipsList(row.id);
  511. if (res.code == 200) {
  512. this.$message.success("删除成功");
  513. this.queryTipsList();
  514. } else {
  515. this.$message({
  516. message: res.msg,
  517. type: "error"
  518. });
  519. }
  520. } catch (err) {
  521. }
  522. }
  523. }
  524. };
  525. </script>
  526. <style scoped>
  527. .content {
  528. background: #fff;
  529. margin-top: 15px;
  530. }
  531. .add-button {
  532. margin-top: 15px;
  533. }
  534. .search-button {
  535. display: flex;
  536. }
  537. </style>