editColumnReport.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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. });
  189. if (resSave.Ret === 200) {
  190. this.$util.toast("已发布");
  191. uni.navigateBack();
  192. }
  193. }
  194. }
  195. },
  196. });
  197. },
  198. searchHandle() {
  199. this.lableActive == 1 ? this.getIndustryList() : this.getCompanySearch();
  200. },
  201. // 获取行业标签
  202. async getIndustryList() {
  203. const res = await purchaserApi.yanxuanSpecialIndustrySearch({
  204. Keyword: this.columnName.replace(/\s+/g, ""),
  205. });
  206. if (res.Ret === 200) {
  207. this.industryLabel = res.Data;
  208. }
  209. },
  210. // 获取公司标签
  211. async getCompanySearch() {
  212. const res = await purchaserApi.yanxuanSpecialCompanySearch({
  213. Keyword: this.columnName.replace(/\s+/g, ""),
  214. });
  215. if (res.Ret === 200) {
  216. this.companyLable = res.Data;
  217. }
  218. },
  219. delImage(done) {
  220. uni.showModal({
  221. content: "是否删除?",
  222. success: (res) => {
  223. if (res.confirm) {
  224. // 执行 done() 删除
  225. done();
  226. }
  227. },
  228. });
  229. },
  230. addImage(e) {
  231. this.$util.upload.Single(
  232. uploadurl,
  233. (res) => {
  234. let data = JSON.parse(res.data);
  235. if (data.Ret === 200) {
  236. this.fileList.push(data.Data.ResourceUrl);
  237. }
  238. },
  239. "camera"
  240. );
  241. },
  242. // 获取专栏详情
  243. async getDetaliData() {
  244. const res = await purchaserApi.yanxuanSpecialDetail({
  245. Id: this.detailId,
  246. });
  247. if (res.Ret === 200) {
  248. this.detailDataForm = res.Data;
  249. this.articleTitle = this.detailDataForm.Title;
  250. this.advice_content = this.detailDataForm.Content;
  251. this.selectedLableList = this.detailDataForm.IndustryTags || [];
  252. this.companySelectedLable = this.detailDataForm.CompanyTags || [];
  253. setTimeout(() => {
  254. this.industryCompanyLable = [...this.selectedLableList, ...this.companySelectedLable];
  255. this.editorCtx.setContents({
  256. html: this.detailDataForm.Content, //this.EditGoodsDetail.content为赋值内容。
  257. });
  258. }, 200);
  259. this.fileList = this.detailDataForm.ImgUrl ? this.detailDataForm.ImgUrl.split(",") : [];
  260. }
  261. },
  262. editorFocus() {
  263. uni.pageScrollTo({
  264. scrollTop: 0,
  265. duration: 0,
  266. });
  267. },
  268. },
  269. onLoad(options) {
  270. uni
  271. .createSelectorQuery()
  272. .in(this)
  273. .select("#editor")
  274. .context((res2) => {
  275. this.editorCtx = res2.context;
  276. })
  277. .exec();
  278. this.detailId = Number(options.id) || 0;
  279. this.detailId > 0 && this.getDetaliData();
  280. this.getIndustryList();
  281. },
  282. };
  283. </script>
  284. <style lang="scss" scope>
  285. .write-note {
  286. overflow: hidden;
  287. background-color: $uni-bg-color;
  288. padding-bottom: 200rpx;
  289. .write-note-content {
  290. background-color: #fff;
  291. margin-top: 1rpx;
  292. padding: 30rpx;
  293. .title-note {
  294. width: 100%;
  295. height: 112rpx;
  296. display: flex;
  297. align-items: center;
  298. border-bottom: 2rpx solid $uni-bg-color;
  299. input {
  300. height: 100%;
  301. width: 100%;
  302. }
  303. }
  304. .content-note {
  305. width: 100%;
  306. height: 880rpx;
  307. padding-top: 20rpx;
  308. font-size: 32rpx;
  309. .ql-container {
  310. height: calc(100% - 80rpx);
  311. }
  312. .new-lable {
  313. margin-top: 20px;
  314. color: #376cbb;
  315. display: flex;
  316. width: 100%;
  317. overflow: hidden;
  318. overflow-x: auto;
  319. .lable-li {
  320. flex-shrink: 0;
  321. display: flex;
  322. align-items: center;
  323. margin: 0 20rpx 30rpx 0;
  324. height: 56rpx;
  325. padding: 0 24rpx;
  326. border-radius: 153rpx;
  327. background-color: #f8f8fa;
  328. }
  329. .active {
  330. background-color: #376cbb;
  331. color: #fff;
  332. }
  333. }
  334. }
  335. }
  336. .write-note-img {
  337. margin-top: 20rpx;
  338. background-color: #fff;
  339. width: 100%;
  340. padding: 20rpx;
  341. .image-add-upload {
  342. width: 100%;
  343. }
  344. }
  345. .write-note-button {
  346. display: flex;
  347. align-items: center;
  348. font-size: 28rpx;
  349. font-weight: 600;
  350. color: #376cbb;
  351. }
  352. .lable-class-popup {
  353. padding: 30rpx;
  354. }
  355. .add-lable-box {
  356. font-size: 28rpx;
  357. width: 100%;
  358. .add-txt {
  359. position: relative;
  360. height: 60rpx;
  361. line-height: 60rpx;
  362. font-weight: 600;
  363. font-size: 36rpx;
  364. color: #000;
  365. text-align: center;
  366. view {
  367. position: absolute;
  368. top: 0;
  369. right: 20rpx;
  370. color: #376cbb;
  371. font-size: 28rpx;
  372. }
  373. }
  374. .select-item {
  375. display: flex;
  376. margin: 20rpx 0;
  377. .item {
  378. width: 176rpx;
  379. height: 64rpx;
  380. border-radius: 100rpx;
  381. display: flex;
  382. align-items: center;
  383. justify-content: center;
  384. background-color: #f3f3f3;
  385. margin-right: 30rpx;
  386. }
  387. .act-item {
  388. color: #376cbb;
  389. background-color: #e5efff;
  390. }
  391. }
  392. .input-box {
  393. background-color: #f3f3f3;
  394. display: flex;
  395. align-items: center;
  396. height: 80rpx;
  397. width: 100%;
  398. position: relative;
  399. padding-left: 50rpx;
  400. padding-right: 20rpx;
  401. input {
  402. background-color: #f3f3f3;
  403. flex: 1;
  404. height: 80rpx;
  405. }
  406. .sea_ico {
  407. position: absolute;
  408. width: 31rpx;
  409. height: 31rpx;
  410. left: 10rpx;
  411. top: 50%;
  412. transform: translateY(-50%);
  413. }
  414. }
  415. .text-box {
  416. color: #333;
  417. font-size: 28rpx;
  418. font-weight: 600;
  419. display: flex;
  420. justify-content: space-between;
  421. margin: 30rpx 0;
  422. .one-lable-text {
  423. color: #999;
  424. font-size: 24rpx;
  425. font-weight: 400;
  426. }
  427. }
  428. .lable-ul {
  429. display: flex;
  430. flex-wrap: wrap;
  431. overflow: hidden;
  432. overflow-y: auto;
  433. .lable-li {
  434. flex-shrink: 0;
  435. display: flex;
  436. align-items: center;
  437. margin: 0 20rpx 30rpx 0;
  438. height: 56rpx;
  439. padding: 0 24rpx;
  440. border-radius: 153rpx;
  441. background-color: #f8f8fa;
  442. }
  443. .active {
  444. background-color: #376cbb;
  445. color: #fff;
  446. }
  447. }
  448. .lable-ul-two {
  449. height: 500rpx;
  450. }
  451. }
  452. .write-note-top {
  453. display: flex;
  454. justify-content: space-between;
  455. background-color: #fff;
  456. padding: 0 35rpx;
  457. .write-text {
  458. display: flex;
  459. align-items: center;
  460. justify-content: center;
  461. font-size: 28rpx;
  462. width: 148rpx;
  463. height: 64rpx;
  464. padding: 10rpx 32rpx 10rpx 32rpx;
  465. border: 1rpx solid #e7e7e7;
  466. }
  467. view:nth-child(1) {
  468. border-radius: 6rpx 0rpx 0rpx 6rpx;
  469. }
  470. view:nth-child(2) {
  471. border-radius: 0rpx 6rpx 6rpx 0rpx;
  472. }
  473. .act-top-lable {
  474. background-color: #376cbb;
  475. color: #fff;
  476. border: none;
  477. }
  478. }
  479. }
  480. </style>