editColumnReport.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <template>
  2. <view class="container write-note">
  3. <view class="write-note-top">
  4. <view style="display: flex">
  5. <view @click="topLableHandler(item)" :class="['write-text', topLableActive == item.value && 'act-top-lable']" v-for="item in topLableList" :key="item.value"> {{ item.name }}</view>
  6. </view>
  7. <view class="write-note-button" @click="releaseBtnHandler"> 修改并发布 </view>
  8. </view>
  9. <view class="write-note-content">
  10. <view class="title-note global_title"> <input v-model="articleTitle" placeholder="请输入标题" /></view>
  11. <view class="content-note" :style="{ height: editorHeight + 'rpx' }">
  12. <editor @focus="editorFocus" :adjust-position="false" id="editor" v-model="advice_content" placeholder="请输入正文(更轻松的创作,上传文档,请先登录查研观向网页版)" @input="contentChange" />
  13. <view class="new-lable" @click="showPopup = true">
  14. <view style="flex-shrink: 0">+ 标签(至少添加一个)</view>
  15. <view v-for="item in industryCompanyLable" :key="item" class="lable-li active">
  16. {{ item }}
  17. <van-icon name="cross" style="margin-left: 8rpx" />
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="write-note-img">
  23. <robbyImageUpload v-model="fileList" :addImage="addImage" :delImage="delImage"></robbyImageUpload>
  24. </view>
  25. <van-popup :show="showPopup" position="bottom" custom-style="height: 85%;" round custom-class="lable-class-popup">
  26. <viwe class="add-lable-box">
  27. <view class="add-txt"> 添加标签 <view @click="addCompleteHandler"> 完成 </view></view>
  28. <view class="select-item">
  29. <view @click="industryOfCompanyHanler(item)" v-for="item in lableList" :key="item.value" :class="['item', lableActive == item.value && 'act-item']"> {{ item.name }}</view>
  30. </view>
  31. <view class="input-box">
  32. <icon type="search" size="15" class="sea_ico" />
  33. <input v-model="columnName" :placeholder="lableActive == 2 ? '搜索公司标签' : '搜索行业标签'" @input="searchHandle" />
  34. <view v-if="lableActive == 2" style="color: #376cbb" @click="addCompanyLableHandler">+ &nbsp;创建</view>
  35. </view>
  36. <view class="text-box"> 已选标签 <view class="one-lable-text"> 至少添加一个标签 </view></view>
  37. <view class="lable-ul">
  38. <block v-if="lableActive == 1">
  39. <view :class="['lable-li', 'active']" v-for="item in selectedLableList" :key="item">
  40. {{ item }}
  41. <van-icon name="cross" style="margin-left: 8rpx" @click="selectedLableHandle(item)" />
  42. </view>
  43. </block>
  44. <block v-else>
  45. <view :class="['lable-li', 'active']" v-for="item in companySelectedLable" :key="item">
  46. {{ item }}
  47. <van-icon name="cross" style="margin-left: 8rpx" @click="selectedLableHandle(item)" />
  48. </view>
  49. </block>
  50. </view>
  51. <view class="text-box"> 标签</view>
  52. <view class="lable-ul lable-ul-two">
  53. <!-- 这里就不用计算属性了 不知道会不会有隐藏的问题 -->
  54. <block v-if="lableActive == 1">
  55. <view :class="['lable-li']" @click="industryLabelHandler(item)" v-for="item in industryLabel" :key="item">{{ item }}</view>
  56. </block>
  57. <block v-else>
  58. <block v-for="item in companyLable" :key="item">
  59. <view :class="['lable-li']" @click="industryLabelHandler(item)" v-if="!item.search">
  60. {{ item }}
  61. </view>
  62. </block>
  63. </block>
  64. </view>
  65. </viwe>
  66. </van-popup>
  67. <Loading />
  68. </view>
  69. </template>
  70. <script>
  71. import robbyImageUpload from "../components/imageUpload.vue";
  72. import { purchaserApi, uploadurl } from "@/config/api";
  73. export default {
  74. components: { robbyImageUpload },
  75. data() {
  76. return {
  77. navBarStyle: {
  78. height: 60 + "px",
  79. paddingTop: 40 + "px",
  80. paddingBottom: "4px",
  81. },
  82. showPopup: false,
  83. fileList: [],
  84. articleTitle: "", // 标题
  85. advice_content: "",
  86. columnName: "",
  87. industryCompanyLable: [], //添加的标签
  88. lableList: [
  89. { name: "行业标签", value: 1 },
  90. { name: "公司标签", value: 2 },
  91. ], // 公司或者行业标签
  92. lableActive: 1,
  93. topLableList: [
  94. { name: "笔记", value: 1 },
  95. { name: "观点", value: 2 },
  96. ], // 笔记或者观点的标签
  97. topLableActive: 1, // 笔记或者观点的选中
  98. industryLabel: [], // 行业标签
  99. selectedLableList: [], // 行业标签已选项
  100. companyLable: [], // 公司标签
  101. companySelectedLable: [], // 公司标签已选项
  102. detailId: 0,
  103. detailDataForm: {},
  104. editorCtx: null,
  105. editorHeight: 800,
  106. };
  107. },
  108. computed: {},
  109. methods: {
  110. // 添加标签完成事件
  111. addCompleteHandler() {
  112. this.columnName = "";
  113. this.industryCompanyLable = [...this.selectedLableList, ...this.companySelectedLable];
  114. this.showPopup = false;
  115. },
  116. // 创建标签公司Lable
  117. addCompanyLableHandler() {
  118. if (!this.columnName) return;
  119. if (this.companySelectedLable.includes(this.columnName.replace(/\s+/g, ""))) return this.$util.toast("标签已存在");
  120. this.companySelectedLable.push(this.columnName.replace(/\s+/g, ""));
  121. },
  122. // 行业公司标签的点击事件
  123. industryOfCompanyHanler(item) {
  124. this.lableActive = item.value;
  125. },
  126. // 内容输入框
  127. contentChange(e) {
  128. this.advice_content = e.detail.html;
  129. },
  130. // 头部 table 的点击事件
  131. topLableHandler(item) {
  132. this.topLableActive = item.value;
  133. },
  134. // 行业的标签点击事件
  135. industryLabelHandler(item) {
  136. if (this.lableActive == 1) {
  137. if (this.selectedLableList.includes(item)) {
  138. let index = this.selectedLableList.findIndex((key) => key == item);
  139. this.selectedLableList.splice(index, 1);
  140. } else {
  141. this.selectedLableList.push(item);
  142. }
  143. } else {
  144. if (this.companySelectedLable.includes(item)) {
  145. let index = this.companySelectedLable.findIndex((key) => key == item);
  146. this.companySelectedLable.splice(index, 1);
  147. } else {
  148. this.companySelectedLable.push(item);
  149. }
  150. }
  151. },
  152. // 点击取消标签的事件
  153. selectedLableHandle(item) {
  154. if (this.lableActive == 1) {
  155. let index = this.selectedLableList.findIndex((key) => key == item);
  156. this.selectedLableList.splice(index, 1);
  157. } else {
  158. let index = this.companySelectedLable.findIndex((key) => key == item);
  159. this.companySelectedLable.splice(index, 1);
  160. }
  161. },
  162. // 发布
  163. releaseBtnHandler() {
  164. if (!this.articleTitle || !this.advice_content || !this.industryCompanyLable.length > 0) {
  165. let str = !this.articleTitle ? "请输入标题" : !this.advice_content ? "请输入内容" : "请至少添加一个标签";
  166. return this.$util.toast(str);
  167. }
  168. uni.showModal({
  169. content: "确定修改并通过此内容的审核吗?",
  170. confirmColor: "#376cbb",
  171. cancelColor: "#606266",
  172. success: async (res) => {
  173. if (res.confirm) {
  174. const resCheck = await purchaserApi.yanxuanSpecialCheck({
  175. Content: this.advice_content,
  176. ImgUrl: this.fileList,
  177. });
  178. if (resCheck.Ret === 200) {
  179. const resSave = await purchaserApi.yanxuanSpecialSave({
  180. Content: this.advice_content,
  181. Title: this.articleTitle,
  182. Type: this.topLableActive,
  183. IndustryTags: this.selectedLableList.join(","),
  184. CompanyTags: this.companySelectedLable.join(","),
  185. ImgUrl: this.fileList.join(","),
  186. DoType: 2,
  187. Id: this.detailId,
  188. IsApprovalPersonnel: true,
  189. });
  190. if (resSave.Ret === 200) {
  191. this.$util.toast("已发布");
  192. uni.navigateBack();
  193. }
  194. }
  195. }
  196. },
  197. });
  198. },
  199. searchHandle() {
  200. this.lableActive == 1 ? this.getIndustryList() : this.getCompanySearch();
  201. },
  202. // 获取行业标签
  203. async getIndustryList() {
  204. const res = await purchaserApi.yanxuanSpecialIndustrySearch({
  205. Keyword: this.columnName.replace(/\s+/g, ""),
  206. });
  207. if (res.Ret === 200) {
  208. this.industryLabel = res.Data;
  209. }
  210. },
  211. // 获取公司标签
  212. async getCompanySearch() {
  213. const res = await purchaserApi.yanxuanSpecialCompanySearch({
  214. Keyword: this.columnName.replace(/\s+/g, ""),
  215. });
  216. if (res.Ret === 200) {
  217. this.companyLable = res.Data;
  218. }
  219. },
  220. delImage(done) {
  221. uni.showModal({
  222. content: "是否删除?",
  223. success: (res) => {
  224. if (res.confirm) {
  225. // 执行 done() 删除
  226. done();
  227. }
  228. },
  229. });
  230. },
  231. addImage(e) {
  232. this.$util.upload.Single(
  233. uploadurl,
  234. (res) => {
  235. let data = JSON.parse(res.data);
  236. if (data.Ret === 200) {
  237. this.fileList.push(data.Data.ResourceUrl);
  238. }
  239. },
  240. "camera"
  241. );
  242. },
  243. // 获取专栏详情
  244. async getDetaliData() {
  245. const res = await purchaserApi.yanxuanSpecialDetail({
  246. Id: this.detailId,
  247. });
  248. if (res.Ret === 200) {
  249. this.detailDataForm = res.Data;
  250. this.articleTitle = this.detailDataForm.Title;
  251. this.advice_content = this.detailDataForm.Content;
  252. this.selectedLableList = this.detailDataForm.IndustryTags || [];
  253. this.companySelectedLable = this.detailDataForm.CompanyTags || [];
  254. setTimeout(() => {
  255. this.industryCompanyLable = [...this.selectedLableList, ...this.companySelectedLable];
  256. this.editorCtx.setContents({
  257. html: this.detailDataForm.Content, //this.EditGoodsDetail.content为赋值内容。
  258. });
  259. }, 200);
  260. this.fileList = this.detailDataForm.ImgUrl ? this.detailDataForm.ImgUrl.split(",") : [];
  261. }
  262. },
  263. editorFocus() {
  264. uni.pageScrollTo({
  265. scrollTop: 0,
  266. duration: 0,
  267. });
  268. },
  269. },
  270. onLoad(options) {
  271. uni
  272. .createSelectorQuery()
  273. .in(this)
  274. .select("#editor")
  275. .context((res2) => {
  276. this.editorCtx = res2.context;
  277. })
  278. .exec();
  279. this.detailId = Number(options.id) || 0;
  280. this.detailId > 0 && this.getDetaliData();
  281. this.getIndustryList();
  282. },
  283. };
  284. </script>
  285. <style lang="scss" scope>
  286. .write-note {
  287. overflow: hidden;
  288. background-color: $uni-bg-color;
  289. padding-bottom: 200rpx;
  290. .write-note-content {
  291. background-color: #fff;
  292. margin-top: 1rpx;
  293. padding: 30rpx;
  294. .title-note {
  295. width: 100%;
  296. height: 112rpx;
  297. display: flex;
  298. align-items: center;
  299. border-bottom: 2rpx solid $uni-bg-color;
  300. input {
  301. height: 100%;
  302. width: 100%;
  303. }
  304. }
  305. .content-note {
  306. width: 100%;
  307. height: 880rpx;
  308. padding-top: 20rpx;
  309. font-size: 32rpx;
  310. .ql-container {
  311. height: calc(100% - 80rpx);
  312. }
  313. .new-lable {
  314. margin-top: 20px;
  315. color: #376cbb;
  316. display: flex;
  317. width: 100%;
  318. overflow: hidden;
  319. overflow-x: auto;
  320. .lable-li {
  321. flex-shrink: 0;
  322. display: flex;
  323. align-items: center;
  324. margin: 0 20rpx 30rpx 0;
  325. height: 56rpx;
  326. padding: 0 24rpx;
  327. border-radius: 153rpx;
  328. background-color: #f8f8fa;
  329. }
  330. .active {
  331. background-color: #376cbb;
  332. color: #fff;
  333. }
  334. }
  335. }
  336. }
  337. .write-note-img {
  338. margin-top: 20rpx;
  339. background-color: #fff;
  340. width: 100%;
  341. padding: 20rpx;
  342. .image-add-upload {
  343. width: 100%;
  344. }
  345. }
  346. .write-note-button {
  347. display: flex;
  348. align-items: center;
  349. font-size: 28rpx;
  350. font-weight: 600;
  351. color: #376cbb;
  352. }
  353. .lable-class-popup {
  354. padding: 30rpx;
  355. }
  356. .add-lable-box {
  357. font-size: 28rpx;
  358. width: 100%;
  359. .add-txt {
  360. position: relative;
  361. height: 60rpx;
  362. line-height: 60rpx;
  363. font-weight: 600;
  364. font-size: 36rpx;
  365. color: #000;
  366. text-align: center;
  367. view {
  368. position: absolute;
  369. top: 0;
  370. right: 20rpx;
  371. color: #376cbb;
  372. font-size: 28rpx;
  373. }
  374. }
  375. .select-item {
  376. display: flex;
  377. margin: 20rpx 0;
  378. .item {
  379. width: 176rpx;
  380. height: 64rpx;
  381. border-radius: 100rpx;
  382. display: flex;
  383. align-items: center;
  384. justify-content: center;
  385. background-color: #f3f3f3;
  386. margin-right: 30rpx;
  387. }
  388. .act-item {
  389. color: #376cbb;
  390. background-color: #e5efff;
  391. }
  392. }
  393. .input-box {
  394. background-color: #f3f3f3;
  395. display: flex;
  396. align-items: center;
  397. height: 80rpx;
  398. width: 100%;
  399. position: relative;
  400. padding-left: 50rpx;
  401. padding-right: 20rpx;
  402. input {
  403. background-color: #f3f3f3;
  404. flex: 1;
  405. height: 80rpx;
  406. }
  407. .sea_ico {
  408. position: absolute;
  409. width: 31rpx;
  410. height: 31rpx;
  411. left: 10rpx;
  412. top: 50%;
  413. transform: translateY(-50%);
  414. }
  415. }
  416. .text-box {
  417. color: #333;
  418. font-size: 28rpx;
  419. font-weight: 600;
  420. display: flex;
  421. justify-content: space-between;
  422. margin: 30rpx 0;
  423. .one-lable-text {
  424. color: #999;
  425. font-size: 24rpx;
  426. font-weight: 400;
  427. }
  428. }
  429. .lable-ul {
  430. display: flex;
  431. flex-wrap: wrap;
  432. overflow: hidden;
  433. overflow-y: auto;
  434. .lable-li {
  435. flex-shrink: 0;
  436. display: flex;
  437. align-items: center;
  438. margin: 0 20rpx 30rpx 0;
  439. height: 56rpx;
  440. padding: 0 24rpx;
  441. border-radius: 153rpx;
  442. background-color: #f8f8fa;
  443. }
  444. .active {
  445. background-color: #376cbb;
  446. color: #fff;
  447. }
  448. }
  449. .lable-ul-two {
  450. height: 500rpx;
  451. }
  452. }
  453. .write-note-top {
  454. display: flex;
  455. justify-content: space-between;
  456. background-color: #fff;
  457. padding: 0 35rpx;
  458. .write-text {
  459. display: flex;
  460. align-items: center;
  461. justify-content: center;
  462. font-size: 28rpx;
  463. width: 148rpx;
  464. height: 64rpx;
  465. padding: 10rpx 32rpx 10rpx 32rpx;
  466. border: 1rpx solid #e7e7e7;
  467. }
  468. view:nth-child(1) {
  469. border-radius: 6rpx 0rpx 0rpx 6rpx;
  470. }
  471. view:nth-child(2) {
  472. border-radius: 0rpx 6rpx 6rpx 0rpx;
  473. }
  474. .act-top-lable {
  475. background-color: #376cbb;
  476. color: #fff;
  477. border: none;
  478. }
  479. }
  480. }
  481. </style>