addSummarizing.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <!-- 上周研究汇总添加/编辑 -->
  3. <div class="add-summarizing">
  4. <el-card>
  5. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm">
  6. <el-row :gutter="24">
  7. <el-col :span="12">
  8. <el-form-item prop="title">
  9. <el-input v-model="ruleForm.title" placeholder="请输入标题"></el-input>
  10. </el-form-item>
  11. </el-col>
  12. <el-col :span="6">
  13. <el-form-item prop="author">
  14. <el-input v-model="ruleForm.author" placeholder="请输入作者"></el-input>
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="6">
  18. <el-form-item prop="time">
  19. <el-date-picker type="date" placeholder="选择发布时间" value-format="yyyy-MM-dd" v-model="ruleForm.time"></el-date-picker>
  20. </el-form-item>
  21. </el-col>
  22. </el-row>
  23. <el-form-item prop="explain">
  24. <el-input v-model="ruleForm.explain" placeholder="请输入摘要"></el-input>
  25. </el-form-item>
  26. </el-form>
  27. <!-- //产业调研纪要篇 -->
  28. <div class="content-list">
  29. <div class="list-top">
  30. <span>产业调研纪要篇</span>
  31. <input maxlength="1" :class="isSortCydyjyShow ? '' : 'red'" v-model="SortCydyjy" placeholder="序号" onkeyup="value=value.replace(/[^A-Z]/g,'')" />
  32. <el-tooltip style="margin-left: 5px" class="item" placement="top-start">
  33. <div slot="content">
  34. 一级分类的序号请以大写字母A\B\C\D...排序 <br />
  35. 二级分类请以1\2\3\4...排序
  36. </div>
  37. <i class="el-icon-info"></i>
  38. </el-tooltip>
  39. </div>
  40. <div class="list-ul" v-for="(item, index) in ListCydyjy" :key="item.ChartPermissionId">
  41. <div class="list-title">
  42. <img :src="item.IcoLink" alt="" />
  43. <span>{{ item.ChartPermissionName }}</span>
  44. <input maxlength="1" placeholder="序号" :class="item.isShow ? 'red' : ''" v-model="item.ChartPermissionSort" onkeyup="value=value.replace(/[^\d]/g,'')" />
  45. </div>
  46. <div class="list-li">
  47. <div v-for="(val, num) in item.List" :key="num" class="list-children">
  48. <div class="box">
  49. <froala :id="num + 'froalaCy'" :ref="num + 'froalaCy'" :tag="'textarea'" :config="froalaConfig" v-model="val.Body"></froala>
  50. <el-input v-model="val.ReportLink" placeholder="请输入报告链接"></el-input>
  51. </div>
  52. <img @click="deleteListSdbg(item, num, index, '产业调研纪要篇')" src="~@/assets/img/icons/delete-Item.png" />
  53. </div>
  54. <p @click="addListSdbg(item, index, '产业调研纪要篇')" :class="item.List && item.List.length > 0 ? 'active' : ''">+添加栏目</p>
  55. </div>
  56. </div>
  57. </div>
  58. <!-- //上市公司调研纪要篇 -->
  59. <div class="content-list">
  60. <div class="list-top">
  61. <span>上市公司调研纪要篇</span>
  62. <input maxlength="1" :class="isSortSsgsShow ? '' : 'red'" v-model="SortSsgs" placeholder="序号" onkeyup="value=value.replace(/[^A-Z]/g,'')" />
  63. </div>
  64. <div class="list-ul" v-for="(item, index) in ListSsgs" :key="item.ChartPermissionId">
  65. <div class="list-title">
  66. <img :src="item.IcoLink" alt="" />
  67. <span>{{ item.ChartPermissionName }}</span>
  68. <input maxlength="1" placeholder="序号" :class="item.isShow ? 'red' : ''" v-model="item.ChartPermissionSort" onkeyup="value=value.replace(/[^\d]/g,'')" />
  69. </div>
  70. <div class="list-li">
  71. <div v-for="(val, num) in item.List" :key="num" class="list-children">
  72. <div class="box">
  73. <froala :id="num + 'froalaCy'" :ref="num + 'froalaCy'" :tag="'textarea'" :config="froalaConfig" v-model="val.Body"></froala>
  74. <el-input v-model="val.ReportLink" placeholder="请输入报告链接"></el-input>
  75. </div>
  76. <img @click="deleteListSdbg(item, num, index, '上市公司调研纪要篇')" src="~@/assets/img/icons/delete-Item.png" />
  77. </div>
  78. <p @click="addListSdbg(item, index, '上市公司调研纪要篇')" :class="item.List && item.List.length > 0 ? 'active' : ''">+添加栏目</p>
  79. </div>
  80. </div>
  81. </div>
  82. <!-- 研选纪要
  83. <div class="content-list">
  84. <div class="list-top">
  85. <span>买方研选纪要</span>
  86. <input maxlength="1" :class="isSortSummaryShow ? '' : 'red'" v-model="SortYanx" placeholder="序号" onkeyup="value=value.replace(/[^A-Z]/g,'')" />
  87. </div>
  88. <div class="list-ul">
  89. <div class="list-li">
  90. <div v-for="(item, index) in ListYanx" :key="index" class="list-children">
  91. <div class="box">
  92. <froala :id="item + 'froalaDp'" :ref="item + 'froalaDp'" :tag="'textarea'" :config="froalaConfig" v-model="item.Body"></froala>
  93. <el-input v-model="item.ReportLink" :class="item.isShow ? 'red' : ''" placeholder="请输入报告链接"></el-input>
  94. </div>
  95. <img @click="deleteList(item, index)" src="~@/assets/img/icons/delete-Item.png" />
  96. </div>
  97. <p @click="addList" :class="ListYanx && ListYanx.length > 0 ? 'active' : ''">+添加栏目</p>
  98. </div>
  99. </div>
  100. </div> -->
  101. <div class="more-button">
  102. <el-button type="primary" @click="confirm('预览')">预览</el-button>
  103. <el-button type="primary" @click="confirm('保存')">保存</el-button>
  104. <el-button v-if="isShowStatus" type="primary" @click="confirm('发布')">发布</el-button>
  105. <el-button type="" @click="cancel">取消</el-button>
  106. </div>
  107. </el-card>
  108. </div>
  109. </template>
  110. <script>
  111. import { raiInterface } from "@/api/api.js";
  112. import mixinsRichText from "./selection/mixins";
  113. export default {
  114. name: "",
  115. components: {},
  116. props: {},
  117. data() {
  118. var that = this;
  119. return {
  120. // ListYanx: [],
  121. isShowStatus: true,
  122. // isSortSummaryShow: true,
  123. // SortYanx: "",
  124. };
  125. },
  126. mixins: [mixinsRichText],
  127. computed: {},
  128. watch: {},
  129. created() {},
  130. mounted() {
  131. // window.addEventListener('beforeunload', e => {
  132. // window.event.returnValue = "刷新/关闭"
  133. // })
  134. window.addEventListener("beforeunload", this.beforeunloadFn);
  135. if (this.$route.query.id) {
  136. this.getDetail();
  137. } else {
  138. this.getList();
  139. }
  140. },
  141. destroyed() {
  142. window.removeEventListener("beforeunload", this.beforeunloadFn);
  143. },
  144. methods: {
  145. beforeunloadFn(e) {
  146. e = e || window.event;
  147. if (e) {
  148. e.returnValue = "关闭提示";
  149. }
  150. return "关闭提示";
  151. },
  152. async getList() {
  153. const res = await raiInterface.chartPermissiondetailTemplate();
  154. if (res.Ret === 200) {
  155. this.ListCydyjy = res.Data.ListCydyjy;
  156. this.SortCydyjy = res.Data.SortCydyjy;
  157. this.ListSsgs = res.Data.ListSsgs;
  158. this.SortSsgs = res.Data.SortSsgs;
  159. // this.ListYanx.forEach(item => item.isShow = true);
  160. }
  161. },
  162. //删除 list
  163. // deleteList(item, num, index) {
  164. // this.ListYanx.splice(num, 1);
  165. // },
  166. //添加 list
  167. // addList() {
  168. // this.ListYanx.push({ Body: "", ReportLink: "" });
  169. // },
  170. //获取详情
  171. async getDetail() {
  172. const res = await raiInterface.minutesSummaryDetail({
  173. ArticleId: this.$route.query.id,
  174. });
  175. if (res.Ret === 200) {
  176. this.initGetList(res.Data.ListCydyjy);
  177. this.initGetList(res.Data.ListSsgs);
  178. this.ListCydyjy = res.Data.ListCydyjy;
  179. this.SortCydyjy = res.Data.SortCydyjy;
  180. this.ListSsgs = res.Data.ListSsgs;
  181. this.SortSsgs = res.Data.SortSsgs;
  182. // this.ListYanx = res.Data.ListYanx || [];
  183. // this.SortYanx = res.Data.SortYanx;
  184. this.isShowStatus = res.Data.PublishStatus == 0;
  185. this.ruleForm = {
  186. title: res.Data.Title, //标题
  187. author: res.Data.Department, //作者
  188. time: res.Data.PublishDate, //时间
  189. explain: res.Data.Abstract, //说明
  190. };
  191. }
  192. },
  193. //保存 发布
  194. confirm: _.debounce(function (type) {
  195. this.$refs.ruleForm.validate(async (val) => {
  196. if (!val) return;
  197. const isFlag = await this.fnConFirm();
  198. if (isFlag) return;
  199. let params = {
  200. Abstract: this.ruleForm.explain,
  201. ArticleId: this.$route.query.id ? Number(this.$route.query.id) : 0,
  202. Department: this.ruleForm.author,
  203. DoType: type == "发布" ? 1 : 0,
  204. PublishDate: this.ruleForm.time.replace(/\./g, "-"),
  205. Title: this.ruleForm.title,
  206. List: this.dataList,
  207. Content: {
  208. ListCydyjy: this.ListCydyjy,
  209. ListSsgs: this.ListSsgs,
  210. // ListYanx: this.ListYanx,
  211. SortCydyjy: this.SortCydyjy,
  212. SortSsgs: this.SortSsgs,
  213. // SortYanx: this.SortYanx,
  214. },
  215. };
  216. if (type == "预览") {
  217. sessionStorage.setItem("lastWeekPre", JSON.stringify(params));
  218. let { href } = this.$router.resolve({ name: "预览上周汇总" });
  219. window.open(href, "_blank");
  220. } else {
  221. const res = await raiInterface.minutesSummaryPreserveAndPublish(params);
  222. if (res.Ret === 200) {
  223. this.$message.success(`${type}成功!`);
  224. this.$refs["ruleForm"].resetFields();
  225. this.$router.back();
  226. }
  227. }
  228. });
  229. }, 500),
  230. fnConFirm() {
  231. let flag = false;
  232. let isCydyjy = this.ListCydyjy.some((item) => item.List.length > 0);
  233. let Ssgs = this.ListSsgs.some((item) => item.List.length > 0);
  234. this.isSortCydyjyShow = !(isCydyjy && !this.SortCydyjy);
  235. this.isSortSsgsShow = !(Ssgs && !this.SortSsgs);
  236. // this.isSortSummaryShow = !(this.ListYanx.length !== 0 && !this.SortYanx);
  237. // || (!this.SortYanx && this.ListYanx.length > 0)
  238. if ((isCydyjy && !this.SortCydyjy) || (Ssgs && !this.SortSsgs) ) {
  239. this.$message.warning("有内容的报告分类和行业分类,序号不能为空");
  240. return (flag = true);
  241. }
  242. // , this.SortYanx
  243. let str = new Array(this.SortCydyjy, this.SortSsgs);
  244. let isStr = str.sort();
  245. for (var i = 0; i < isStr.length - 1; i++) {
  246. if (isStr[i] == isStr[i + 1] && (isStr[i] || isStr[i + 1])) {
  247. this.$message.warning("请勿填写重复的序号!");
  248. return (flag = true);
  249. }
  250. }
  251. let chidrenCydyjy = this.chidrenList(this.ListCydyjy);
  252. let chidrenSsgs = this.chidrenList(this.ListSsgs);
  253. if (chidrenCydyjy || chidrenSsgs) {
  254. this.$message.warning("有内容行业分类,序号不能为空");
  255. return (flag = true);
  256. }
  257. },
  258. //取消
  259. cancel() {
  260. this.$refs["ruleForm"].resetFields();
  261. this.$router.back();
  262. },
  263. },
  264. };
  265. </script>
  266. <style scoped lang="scss">
  267. .add-summarizing {
  268. @import "./selection/strictSelection.scss";
  269. }
  270. </style>