addFeedbackMoal.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <div class="modal-backdrop">
  3. <div class="modal">
  4. <div class="modal-header">
  5. <span>新增</span>
  6. </div>
  7. <div class="modal-body">
  8. <div class="bodyRow">
  9. <span>资料名称</span>
  10. <div>{{ fileName }}</div>
  11. </div>
  12. <div class="bodyRow timeWidth">
  13. <span>发布时间</span
  14. ><input
  15. type="date"
  16. placeholder="选择时间"
  17. :max="localDay"
  18. v-model="ziliaoTime"
  19. />
  20. </div>
  21. <div class="bodyRow">
  22. <div class="contentCol1">
  23. <span>涉及车型</span
  24. ><select v-model="carTypeValue">
  25. <option
  26. v-for="(item, index) in carType"
  27. :key="index"
  28. :value="item.typeName"
  29. >
  30. {{ item.typeName || "123" }}
  31. </option>
  32. </select>
  33. </div>
  34. </div>
  35. <div class="bodyRow">
  36. <div class="contentCol1">
  37. <span>发布渠道</span>
  38. <select
  39. name=""
  40. id=""
  41. v-model="releaseC"
  42. @change="chooseChannel($event)"
  43. >
  44. <option v-for="(item, index) in releaseChannel" :key="index">
  45. {{ item.platformName || "-" }}
  46. </option>
  47. </select>
  48. </div>
  49. <div class="contentCol2">
  50. <span>平台版块</span>
  51. <div v-if="releaseC !== '其它'">
  52. <select name="" id="" v-model="releaseP">
  53. <option v-for="(item, index) in releasePlate" :key="index">
  54. {{ item.platformName || "-" }}
  55. </option>
  56. </select>
  57. </div>
  58. <div v-else>
  59. <input type="text" v-model="releaseP" />
  60. </div>
  61. </div>
  62. </div>
  63. <div class="bodyRow">
  64. <div class="contentCol1">
  65. <span>稿件类别</span>
  66. <select name="" id="" v-model="contentName1">
  67. <option v-for="(item, index) in content1" :key="index">
  68. {{ item.dictName }}
  69. </option>
  70. </select>
  71. </div>
  72. <div class="contentCol2">
  73. <span>内容分类</span
  74. ><select name="" id="" v-model="contentName2">
  75. <option v-for="(item, index) in content2" :key="index">
  76. {{ item.dictName || "-" }}
  77. </option>
  78. </select>
  79. </div>
  80. </div>
  81. <div class="bodyRow">
  82. <div class="contentCol1">
  83. <span>阅读量</span>
  84. <input type="number" placeholder="" min="0" v-model="readCount" />
  85. </div>
  86. <div class="contentCol2">
  87. <span>点赞</span>
  88. <input type="number" placeholder="" min="0" v-model="goodCount" />
  89. </div>
  90. </div>
  91. <div class="bodyRow">
  92. <div class="contentCol1">
  93. <span>评论</span>
  94. <input type="number" placeholder="" min="0" v-model="bbsCount" />
  95. </div>
  96. <div class="contentCol2">
  97. <span>在看/转发</span>
  98. <input
  99. type="number"
  100. placeholder=""
  101. min="0"
  102. v-model="lookingCount"
  103. />
  104. </div>
  105. </div>
  106. <div class="bodyRow longInput">
  107. <span>标题</span>
  108. <input type="text" placeholder="文章标题" v-model="mediaTitle" />
  109. </div>
  110. <div class="bodyRow longInput">
  111. <span>链接</span>
  112. <input type="text" placeholder="文章发布地址" v-model="mediaUrl" />
  113. </div>
  114. </div>
  115. <div class="modal-footer">
  116. <!-- <button type="button" class="btn-confirm" @click="confirm">确认</button> -->
  117. <button type="button" class="btn-confirm" @click="testUrl()">
  118. 确认
  119. </button>
  120. <button type="button" class="btn-close" @click="closeSelf">取消</button>
  121. </div>
  122. </div>
  123. </div>
  124. </template>
  125. <script>
  126. export default {
  127. name: "Modal",
  128. props: {
  129. fileName: {
  130. type: String,
  131. default: "",
  132. },
  133. ziliaoId: {
  134. type: String,
  135. default: "",
  136. },
  137. userId: {
  138. type: String,
  139. default: "",
  140. },
  141. },
  142. data() {
  143. return {
  144. ziliaoTime: "",
  145. carTypeValue: "1",
  146. carType: [],
  147. releaseC: "", //'发布渠道',
  148. releaseChannel: [], // 发布渠道列表
  149. releaseP: "", //'平台版块',
  150. releasePlate: [], // 平台版块
  151. contentName1: "", //"稿件类别",
  152. content1: [],
  153. contentName2: "", //'内容分类',
  154. content2: [],
  155. readCount: 0,
  156. goodCount: 0,
  157. bbsCount: 0,
  158. lookingCount: 0,
  159. mediaTitle: "", //'文章标题',
  160. mediaUrl: "",
  161. dictList: [],
  162. initParentId: "",
  163. localDay: "",
  164. noEditFlag: false,
  165. };
  166. },
  167. methods: {
  168. // 改变发布渠道
  169. chooseChannel: function (e) {
  170. let index = e.target.options.selectedIndex;
  171. let req = {
  172. parentId: this.releaseChannel[index].id,
  173. };
  174. this.channelType(req);
  175. },
  176. // 确认
  177. testUrl: function () {
  178. var regex = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?$/;
  179. let flag = regex.test(this.mediaUrl);
  180. if (flag) {
  181. this.edit();
  182. } else {
  183. alert("链接输入有误!\n示例:https://www.baidu.com");
  184. }
  185. },
  186. // 取消
  187. closeSelf: function () {
  188. this.$emit("closeme");
  189. },
  190. // 判断非空
  191. beforeEdit: function () {
  192. this.releaseP = (this.releaseP || "").replace(/\s/g, "");
  193. this.mediaTitle = (this.mediaTitle || "").replace(/\s/g, "");
  194. if (!this.ziliaoTime) {
  195. this.noEditFlag = true;
  196. alert("发布时间不能为空");
  197. return;
  198. }
  199. if (!this.carTypeValue) {
  200. this.noEditFlag = true;
  201. alert("请选择车型");
  202. return;
  203. }
  204. if (!this.releaseC) {
  205. this.noEditFlag = true;
  206. alert("请选择发布渠道");
  207. return;
  208. }
  209. if (!this.releaseP) {
  210. this.noEditFlag = true;
  211. alert("请选择平台版块");
  212. return;
  213. }
  214. if (!this.contentName1) {
  215. this.noEditFlag = true;
  216. alert("请选择稿件类别");
  217. return;
  218. }
  219. if (!this.contentName2) {
  220. this.noEditFlag = true;
  221. alert("请选择内容分类");
  222. return;
  223. }
  224. if (!this.readCount || this.readCount < 0) {
  225. this.noEditFlag = true;
  226. alert("请填写阅读量");
  227. return;
  228. }
  229. if (!this.goodCount || this.goodCount < 0) {
  230. this.noEditFlag = true;
  231. alert("请填写点赞量");
  232. return;
  233. }
  234. if (!this.bbsCount || this.bbsCount < 0) {
  235. this.noEditFlag = true;
  236. alert("请填写评论量");
  237. return;
  238. }
  239. if (!this.lookingCount || this.lookingCount < 0) {
  240. this.noEditFlag = true;
  241. alert("请填写正确的在看/转发");
  242. return;
  243. }
  244. if (!this.mediaTitle) {
  245. this.noEditFlag = true;
  246. alert("标题不能为空");
  247. return;
  248. }
  249. if (!this.mediaUrl) {
  250. this.noEditFlag = true;
  251. alert("链接不能为空");
  252. return;
  253. }
  254. },
  255. edit() {
  256. this.noEditFlag = false;
  257. this.beforeEdit();
  258. if (!this.noEditFlag) {
  259. //当前月份
  260. let date = new Date();
  261. let m = date.getMonth() + 1;
  262. let y = date.getFullYear();
  263. let d = y + "/" + m;
  264. let config = {
  265. url: "",
  266. data: {
  267. month: d,
  268. dealerId: this.userId,
  269. dataId: this.ziliaoId,
  270. informationName: this.fileName,
  271. releaseTime: this.ziliaoTime,
  272. carType: this.carTypeValue,
  273. releaseMedia: this.releaseC,
  274. releasePlate: this.releaseP,
  275. draftGenre: this.contentName1,
  276. contentClass: this.contentName2,
  277. articleTitle: this.mediaTitle,
  278. articleLink: this.mediaUrl,
  279. readCount: this.readCount,
  280. goodCount: this.goodCount,
  281. bbsCount: this.bbsCount,
  282. lookingCount: this.lookingCount,
  283. },
  284. };
  285. this.$emit("add_feedback", config);
  286. this.closeSelf();
  287. }
  288. },
  289. // 获取当前的月份
  290. getLocalMonth: function () {
  291. let data = new Date();
  292. let year = data.getFullYear();
  293. let month = data.getMonth() + 1;
  294. let day = data.getDate();
  295. if (month < 10) {
  296. month = "0" + month;
  297. } else {
  298. month = month + "";
  299. }
  300. this.localDay = year + "-" + month + "-" + day;
  301. },
  302. getCarType: function () {
  303. this.$http({
  304. method: "post",
  305. url: "/base/carTypeManager/selectCarTypePage",
  306. data: {},
  307. })
  308. .then((res) => {
  309. if (res.data && res.data.code === 200) {
  310. this.carType = res.data.data;
  311. }
  312. })
  313. .catch((err) => {
  314. console.log(err);
  315. });
  316. },
  317. channelType: function (data) {
  318. return new Promise((resolve, reject) => {
  319. this.$http({
  320. url: "/base/publishPlatformManager/selectPublishPlatformPage",
  321. method: "post",
  322. data,
  323. })
  324. .then((res) => {
  325. this.releasePlate = [];
  326. if (res.data.code === 200) {
  327. if (!data) {
  328. this.releaseChannel = res.data.data;
  329. } else {
  330. this.releasePlate = res.data.data;
  331. }
  332. }
  333. resolve();
  334. })
  335. .catch((err) => {
  336. console.log(err);
  337. reject();
  338. });
  339. });
  340. },
  341. // 获取内容分类、媒体平台、常用参数接口的标识,再调接口时需要用到
  342. selectSysDataDictList: function () {
  343. return new Promise((resolve, reject) => {
  344. this.$http({
  345. method: "post",
  346. url: "/sys/dataDict/selectSysDataDictList",
  347. data: {},
  348. })
  349. .then((res) => {
  350. if (res.data && res.data.code === 200) {
  351. this.dictList = res.data.data;
  352. resolve();
  353. }
  354. })
  355. .catch((err) => {
  356. console.log(err);
  357. reject();
  358. });
  359. });
  360. },
  361. getContent1: function () {
  362. this.$http({
  363. method: "post",
  364. url: "/sys/dataDict/selectSysDataDictPage",
  365. data: {
  366. dictCode: this.dictList[1]["dictCode"],
  367. parentId: this.dictList[1]["id"],
  368. },
  369. })
  370. .then((res) => {
  371. if (res.data && res.data.code === 200) {
  372. this.content1 = res.data.data;
  373. }
  374. })
  375. .catch((err) => {
  376. console.log(err);
  377. });
  378. },
  379. getContent2: function () {
  380. this.$http({
  381. method: "post",
  382. url: "/sys/dataDict/selectSysDataDictPage",
  383. data: {
  384. dictCode: this.dictList[2]["dictCode"],
  385. parentId: this.dictList[2]["id"],
  386. },
  387. })
  388. .then((res) => {
  389. if (res.data && res.data.code === 200) {
  390. this.content2 = res.data.data;
  391. }
  392. })
  393. .catch((err) => {
  394. console.log(err);
  395. });
  396. },
  397. },
  398. mounted() {
  399. this.getLocalMonth();
  400. this.getCarType();
  401. this.channelType();
  402. this.selectSysDataDictList().then(() => {
  403. this.getContent1();
  404. this.getContent2();
  405. });
  406. },
  407. };
  408. </script>
  409. <style>
  410. .modal-backdrop {
  411. position: fixed;
  412. top: 0;
  413. right: 0;
  414. bottom: 0;
  415. left: 0;
  416. background-color: #7d9191;
  417. display: flex;
  418. justify-content: center;
  419. align-items: center;
  420. }
  421. .modal {
  422. background-color: #eeeeee;
  423. box-shadow: 2px 2px 20px 1px;
  424. overflow-x: auto;
  425. display: flex;
  426. flex-direction: column;
  427. border-radius: 0px;
  428. width: 1030px;
  429. }
  430. .modal-header {
  431. border-bottom: 1px solid #eee;
  432. color: #313131;
  433. justify-content: space-between;
  434. padding: 15px;
  435. display: flex;
  436. border-bottom: 1px solid #e3e3e3;
  437. }
  438. .modal-header span {
  439. font-size: 16px;
  440. font-weight: bold;
  441. }
  442. .modal-footer {
  443. border-top: 1px solid #eee;
  444. justify-content: center;
  445. padding: 15px;
  446. display: flex;
  447. }
  448. .modal-footer button {
  449. width: 90px;
  450. margin-left: 0px;
  451. }
  452. .modal-footer button:nth-child(1) {
  453. margin-right: 80px;
  454. }
  455. .modal-body {
  456. position: relative;
  457. padding: 20px 120px 20px 180px;
  458. }
  459. .modal-body span,
  460. select,
  461. input,
  462. div {
  463. font-size: 14px;
  464. }
  465. .btn-close,
  466. .btn-confirm {
  467. border-radius: 8px;
  468. margin-left: 16px;
  469. width: 56px;
  470. height: 36px;
  471. border: none;
  472. cursor: pointer;
  473. }
  474. .btn-close {
  475. color: #313131;
  476. background-color: gray;
  477. }
  478. .btn-confirm {
  479. color: #fff;
  480. background-color: #0056a0;
  481. }
  482. .bodyRow {
  483. display: flex;
  484. justify-content: flex-start;
  485. align-items: center;
  486. padding: 4px;
  487. }
  488. .bodyRow span {
  489. width: 80px;
  490. margin: 10px;
  491. }
  492. .bodyRow select {
  493. width: 120px;
  494. }
  495. .bodyRow input {
  496. width: 112px;
  497. }
  498. .longInput input {
  499. width: 476px;
  500. }
  501. .bodyRow select,
  502. input {
  503. padding: 2px;
  504. }
  505. .contentCol1 {
  506. display: flex;
  507. justify-content: flex-start;
  508. align-items: center;
  509. }
  510. .contentCol1 span {
  511. width: 80px;
  512. margin: 10px;
  513. }
  514. .contentCol1 div {
  515. width: 120px;
  516. }
  517. .contentCol2 {
  518. display: flex;
  519. justify-content: flex-end;
  520. align-items: center;
  521. width: 363px;
  522. }
  523. .timeWidth input {
  524. width: 150px;
  525. }
  526. </style>