Modal.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  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>{{ ziliaoName }}</div>
  11. <!-- <select v-model="ziliaoId">
  12. <option
  13. v-for="(item, index) in dataName"
  14. :key="index"
  15. :value="item.id"
  16. >
  17. {{ item.informationName }}
  18. </option>
  19. </select> -->
  20. </div>
  21. <div class="bodyRow timeWidth">
  22. <span>发布时间</span
  23. ><input type="date" placeholder="选择时间" v-model="ziliaoTime" />
  24. </div>
  25. <div class="bodyRow">
  26. <div class="contentCol1">
  27. <span>车系</span
  28. ><select v-model="carS" @change="chooseCarSeries">
  29. <option
  30. v-for="(item, index) in carSeries"
  31. :key="index"
  32. :value="item.typeName"
  33. >
  34. {{ item.typeName }}
  35. </option>
  36. </select>
  37. </div>
  38. <div class="contentCol2">
  39. <span>车型</span
  40. ><select v-model="carT">
  41. <option
  42. v-for="(item, index) in carType"
  43. :key="index"
  44. :value="item.typeName"
  45. >
  46. {{ item.typeName }}
  47. </option>
  48. </select>
  49. </div>
  50. </div>
  51. <div class="bodyRow">
  52. <div class="contentCol1">
  53. <span>发布渠道</span>
  54. <div>{{ selectedPlatform }}</div>
  55. </div>
  56. <div class="contentCol2">
  57. <span>平台版块</span
  58. ><select name="" id="" v-model="releaseP">
  59. <option
  60. v-for="(item, index) in releaseMedia"
  61. :key="index"
  62. :value="item.platformName"
  63. >
  64. {{ item.platformName }}
  65. </option>
  66. </select>
  67. </div>
  68. </div>
  69. <!-- <div class="bodyRow">
  70. <span>项目分类</span
  71. ><select name="" id="">
  72. <option value="">请选择</option>
  73. </select>
  74. </div> -->
  75. <div class="bodyRow">
  76. <div class="contentCol1">
  77. <span>稿件类别</span
  78. ><select name="" id="" v-model="contentName1">
  79. <option
  80. v-for="(item, index) in content1"
  81. :key="index"
  82. :value="item.dictName"
  83. >
  84. {{ item.dictName }}
  85. </option>
  86. </select>
  87. </div>
  88. <div class="contentCol2">
  89. <span>内容分类</span
  90. ><select name="" id="" v-model="contentName2">
  91. <option
  92. v-for="(item, index) in content2"
  93. :key="index"
  94. :value="item.dictName"
  95. >
  96. {{ item.dictName }}
  97. </option>
  98. </select>
  99. </div>
  100. </div>
  101. <div class="bodyRow">
  102. <div class="contentCol1">
  103. <span>阅读量</span>
  104. <input type="number" placeholder="" v-model="readCount" />
  105. </div>
  106. <div class="contentCol2">
  107. <span>点赞</span>
  108. <input type="number" placeholder="" v-model="goodCount" />
  109. </div>
  110. </div>
  111. <div class="bodyRow">
  112. <div class="contentCol1">
  113. <span>评论</span>
  114. <input type="number" placeholder="" v-model="bbsCount" />
  115. </div>
  116. <div class="contentCol2">
  117. <span>在看/转发</span>
  118. <input type="number" placeholder="" v-model="lookingCount" />
  119. </div>
  120. </div>
  121. <div class="bodyRow longInput">
  122. <span>标题</span>
  123. <input type="text" placeholder="文章标题" v-model="mediaTitle" />
  124. </div>
  125. <div class="bodyRow longInput">
  126. <span>链接</span>
  127. <input type="text" placeholder="文章发布地址" v-model="mediaUrl" />
  128. </div>
  129. </div>
  130. <div class="modal-footer">
  131. <!-- <button type="button" class="btn-confirm" @click="confirm">确认</button> -->
  132. <button type="button" class="btn-confirm" @click="testUrl()">
  133. 确认
  134. </button>
  135. <button type="button" class="btn-close" @click="closeSelf">取消</button>
  136. </div>
  137. </div>
  138. </div>
  139. </template>
  140. <script>
  141. export default {
  142. name: "Modal",
  143. props: {
  144. LinkData: {
  145. type: Object,
  146. default: () => {
  147. return {};
  148. },
  149. },
  150. selectedPlatform: {
  151. type: String,
  152. default: () => {
  153. return "";
  154. },
  155. },
  156. releaseMedia: {
  157. type: Array,
  158. default: () => {
  159. return [];
  160. },
  161. },
  162. },
  163. data() {
  164. return {
  165. dataName: [],
  166. carSeries: [],
  167. carType: [],
  168. content1: [],
  169. content2: [],
  170. carS: "",
  171. carT: "",
  172. releaseP: "",
  173. ziliaoId: "",
  174. content1Id: "",
  175. content2Id: "",
  176. carTypeId: "",
  177. contentTypeName: "",
  178. informationId: "",
  179. mediaTitle: "",
  180. mediaUrl: "",
  181. projectTypeName: "",
  182. publishDate: "",
  183. publishSourceName: "",
  184. ziliaoName: "",
  185. ziliaoTime: "",
  186. contentName1: "",
  187. contentName2: "",
  188. readCount: "",
  189. goodCount: "",
  190. bbsCount: "",
  191. lookingCount: "",
  192. };
  193. },
  194. methods: {
  195. closeSelf() {
  196. this.$emit("closeme");
  197. // console.log(this.LinkData);
  198. },
  199. edit: function () {
  200. let obj = {};
  201. //获取资料名
  202. let idVal = this.ziliaoId;
  203. obj = this.dataName.find(function (item) {
  204. return item.id === idVal;
  205. });
  206. this.ziliaoName = obj.informationName;
  207. //获取车系 id
  208. let nameCarS = this.carS;
  209. obj = this.carSeries.find(function (item) {
  210. return item.typeName === nameCarS;
  211. });
  212. console.log("chexi ", obj);
  213. //carTypeId 表示车系 id
  214. this.carTypeId = obj.id;
  215. //获取车型名 this.carT
  216. //获取平台名 this.selectedPlatform,
  217. //当前月份
  218. let date = new Date();
  219. let m = date.getMonth() + 1;
  220. let y = date.getFullYear();
  221. let d = y + "/" + m;
  222. let config = {
  223. url: "",
  224. data: {
  225. id: "", //主键值
  226. month: d,
  227. dealerId: "254",
  228. dataId: this.ziliaoId,
  229. informationName: this.ziliaoName,
  230. releaseTime: this.ziliaoTime,
  231. carService: this.carS,
  232. carType: this.carT,
  233. //发布板块
  234. releasePlate: this.releaseP,
  235. //发布平台
  236. releaseMedia: this.selectedPlatform,
  237. draftGenre: this.contentName1,
  238. //内容分类2?
  239. contentClass: this.contentName2,
  240. articleTitle: this.mediaTitle,
  241. articleLink: this.mediaUrl,
  242. readCount: this.readCount,
  243. goodCount: this.goodCount,
  244. bbsCount: this.bbsCount,
  245. lookingCount: this.lookingCount,
  246. },
  247. };
  248. if (this.LinkData.id) {
  249. //编辑
  250. config.url = "/updateDealerFeedback";
  251. config.data.id = this.LinkData.id;
  252. console.log(config.url);
  253. } else {
  254. //新增
  255. config.url = "/dealerFeedback";
  256. }
  257. this.$emit("update", config);
  258. this.$emit("closeme");
  259. },
  260. addInfo: function () {
  261. let obj = {};
  262. //获取资料名
  263. let idVal = this.ziliaoId;
  264. obj = this.dataName.find(function (item) {
  265. return item.id === idVal;
  266. });
  267. this.ziliaoName = obj.informationName;
  268. //获取车系 id
  269. let nameCarS = this.carS;
  270. obj = this.carSeries.find(function (item) {
  271. return item.typeName === nameCarS;
  272. });
  273. console.log("chexi ", obj);
  274. //carTypeId 表示车系 id
  275. this.carTypeId = obj.id;
  276. //获取车型名 this.carT
  277. //获取平台名 this.selectedPlatform,
  278. //当前月份
  279. let date = new Date();
  280. let m = date.getMonth() + 1;
  281. let y = date.getFullYear();
  282. let d = y + "/" + m;
  283. let config = {
  284. url: "/dealerFeedback",
  285. data: {
  286. // id: "", //主键值
  287. month: d,
  288. dealerId: "254",
  289. dataId: this.ziliaoId,
  290. informationName: this.ziliaoName,
  291. releaseTime: this.ziliaoTime,
  292. carService: this.carS,
  293. carType: this.carT,
  294. //releasePlate: this.selectedPlatform,
  295. //releaseMedia: this.releaseP,
  296. //发布板块
  297. releasePlate: this.releaseP,
  298. //发布平台
  299. releaseMedia: this.selectedPlatform,
  300. draftGenre: this.contentName1,
  301. //内容分类2?
  302. contentClass: this.contentName2,
  303. articleTitle: this.mediaTitle,
  304. articleLink: this.mediaUrl,
  305. readCount: this.readCount,
  306. goodCount: this.goodCount,
  307. bbsCount: this.bbsCount,
  308. lookingCount: this.lookingCount,
  309. },
  310. };
  311. this.$emit("update", config);
  312. this.$emit("closeme");
  313. },
  314. //资料名称列表
  315. chooseDataName: function () {
  316. this.$http({
  317. url: "/firmsUploadListByAgent",
  318. //url: "/firmsLinkUpload",
  319. method: "post",
  320. data: {
  321. download: true,
  322. //report: false,
  323. },
  324. })
  325. .then((res) => {
  326. if (res.data.code === 200) {
  327. this.dataName = res.data.data;
  328. console.log(this.dataName);
  329. //获取资料名
  330. let obj = {};
  331. let idVal = this.ziliaoId;
  332. obj = this.dataName.find(function (item) {
  333. return item.id === idVal;
  334. });
  335. this.ziliaoName = obj.informationName;
  336. }
  337. })
  338. .catch((err) => {
  339. console.log(err);
  340. });
  341. },
  342. //发布版块
  343. /* chooseReleasePlate: function () {}, */
  344. //不分页查询车系车型信息
  345. chooseCarSeries: function () {
  346. this.$http({
  347. url: "/base/carTypeManager/selectCarTypeList",
  348. method: "post",
  349. data: {},
  350. })
  351. .then((res) => {
  352. if (res.data.code === 200) {
  353. this.carSeries = res.data.data;
  354. this.chooseCarType();
  355. }
  356. })
  357. .catch((err) => {
  358. console.log(err);
  359. });
  360. },
  361. chooseCarType: function () {
  362. //清空下级select
  363. this.carT = "";
  364. //获取车系 id
  365. let obj = {};
  366. let nameCarS = this.carS;
  367. obj = this.carSeries.find(function (item) {
  368. return item.typeName === nameCarS;
  369. });
  370. console.log(this.carSeries, obj);
  371. this.carTypeId = obj.id;
  372. this.$http({
  373. url: "/base/carTypeManager/selectCarTypeList",
  374. method: "post",
  375. data: {
  376. parentId: this.carTypeId || -1,
  377. },
  378. })
  379. .then((res) => {
  380. if (res.data.code === 200) {
  381. this.carType = res.data.data;
  382. this.carT = this.LinkData.carPlatformName;
  383. }
  384. })
  385. .catch((err) => {
  386. console.log(err);
  387. });
  388. },
  389. //不分页查询发布平台信息 内容分类1
  390. //初次调用获得 content ID 用作 parentID
  391. firstContent1Classify: function () {
  392. this.$http({
  393. url: "/sys/dataDict/selectSysDataDictList",
  394. method: "post",
  395. data: {
  396. dictCode: "content1",
  397. },
  398. })
  399. .then((res) => {
  400. if (res.data.code === 200) {
  401. this.content1Id = res.data.data[0].id;
  402. this.secondContent1Classify();
  403. }
  404. console.log("contentClassify1", res.data.data[0].id);
  405. })
  406. .catch((err) => {
  407. console.log(err);
  408. });
  409. },
  410. secondContent1Classify: function () {
  411. this.$http({
  412. url: "/sys/dataDict/selectSysDataDictList",
  413. method: "post",
  414. data: {
  415. parentId: this.content1Id,
  416. },
  417. })
  418. .then((res) => {
  419. if (res.data.code === 200) {
  420. this.content1 = res.data.data;
  421. }
  422. console.log("second contentClassify1", res.data.data);
  423. })
  424. .catch((err) => {
  425. console.log(err);
  426. });
  427. },
  428. //不分页查询发布平台信息 内容分类2
  429. firstContent2Classify: function () {
  430. this.$http({
  431. url: "/sys/dataDict/selectSysDataDictList",
  432. method: "post",
  433. data: {
  434. dictCode: "content2",
  435. },
  436. })
  437. .then((res) => {
  438. if (res.data.code === 200) {
  439. this.content2Id = res.data.data[0].id;
  440. this.secondContent2Classify();
  441. }
  442. console.log("contentClassify2", res.data.data[0].id);
  443. })
  444. .catch((err) => {
  445. console.log(err);
  446. });
  447. },
  448. secondContent2Classify: function () {
  449. this.$http({
  450. url: "/sys/dataDict/selectSysDataDictList",
  451. method: "post",
  452. data: {
  453. parentId: this.content2Id,
  454. },
  455. })
  456. .then((res) => {
  457. if (res.data.code === 200) {
  458. this.content2 = res.data.data;
  459. }
  460. console.log("second contentClassify2", res.data.data);
  461. })
  462. .catch((err) => {
  463. console.log(err);
  464. });
  465. },
  466. initialData: function () {
  467. this.ziliaoId = this.LinkData.informationId;
  468. this.mediaTitle = this.LinkData.mediaTitle;
  469. this.mediaUrl = this.LinkData.mediaUrl;
  470. this.carS = this.LinkData.carTypeName;
  471. this.carT = this.LinkData.carPlatformName;
  472. let time = this.LinkData.publishDate; //发布时间
  473. if (time.length > 4) {
  474. let y = time.slice(0, 4);
  475. let m = time.slice(5, 7);
  476. let d = time.slice(8, 10);
  477. let temp = y + "-" + m + "-" + d;
  478. this.ziliaoTime = temp;
  479. }
  480. //console.log("console.log(this.forceUpdate);", typeof time, m, y);
  481. //缺少对应列表值 已有资料名在数据中无法查询到
  482. //publishSourceName 发布板块
  483. this.releaseP = this.LinkData.publishSourceName;
  484. this.contentName1 = this.LinkData.mediaTypeName;
  485. this.contentName2 = this.LinkData.contentTypeName;
  486. this.readCount = this.LinkData.readCount;
  487. this.goodCount = this.LinkData.goodCount;
  488. this.bbsCount = this.LinkData.bbsCount;
  489. this.lookingCount = this.LinkData.lookingCount;
  490. },
  491. testUrl: function () {
  492. var regex = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?$/;
  493. let flag = regex.test(this.mediaUrl);
  494. // console.log(flag, regex);
  495. if (flag) {
  496. if (flag
  497. /* this.ziliaoName &&
  498. this.ziliaoTime &&
  499. this.carS &&
  500. this.carT &&
  501. this.releaseP &&
  502. this.selectedPlatform &&
  503. this.contentName1 &&
  504. this.contentName2 &&
  505. this.mediaTitle &&
  506. this.mediaUrl &&
  507. this.readCount &&
  508. this.goodCount &&
  509. this.bbsCount &&
  510. this.lookingCount */
  511. ) {
  512. this.edit();
  513. } else {
  514. alert("请将信息补充完整!");
  515. }
  516. } else {
  517. alert("链接输入有误!\n示例:https://www.baidu.com");
  518. }
  519. /*
  520. this.ziliaoName && this.ziliaoTime &&this.carS &&this.carT&&
  521. this.releaseP&& this.selectedPlatform&& this.contentName1&&
  522. this.contentName2&& this.mediaTitle&& this.mediaUrl&&
  523. this.readCount&&this.goodCount&& this.bbsCount&& this.lookingCount */
  524. },
  525. },
  526. mounted() {
  527. this.chooseDataName();
  528. this.chooseCarSeries();
  529. this.firstContent1Classify();
  530. this.firstContent2Classify();
  531. //this.chooseReleasePlate();
  532. this.initialData();
  533. },
  534. };
  535. </script>
  536. <style>
  537. .modal-backdrop {
  538. position: fixed;
  539. top: 0;
  540. right: 0;
  541. bottom: 0;
  542. left: 0;
  543. background-color: #7d9191;
  544. display: flex;
  545. justify-content: center;
  546. align-items: center;
  547. }
  548. .modal {
  549. background-color: #eeeeee;
  550. box-shadow: 2px 2px 20px 1px;
  551. overflow-x: auto;
  552. display: flex;
  553. flex-direction: column;
  554. border-radius: 0px;
  555. width: 1030px;
  556. }
  557. .modal-header {
  558. border-bottom: 1px solid #eee;
  559. color: #313131;
  560. justify-content: space-between;
  561. padding: 15px;
  562. display: flex;
  563. border-bottom: 1px solid #e3e3e3;
  564. }
  565. .modal-header span {
  566. font-size: 16px;
  567. font-weight: bold;
  568. }
  569. .modal-footer {
  570. border-top: 1px solid #eee;
  571. justify-content: center;
  572. padding: 15px;
  573. display: flex;
  574. }
  575. .modal-footer button {
  576. width: 90px;
  577. margin-left: 0px;
  578. }
  579. .modal-footer button:nth-child(1) {
  580. margin-right: 80px;
  581. }
  582. .modal-body {
  583. position: relative;
  584. padding: 20px 120px 20px 180px;
  585. }
  586. .modal-body span,
  587. select,
  588. input,
  589. div {
  590. font-size: 14px;
  591. }
  592. .btn-close,
  593. .btn-confirm {
  594. border-radius: 8px;
  595. margin-left: 16px;
  596. width: 56px;
  597. height: 36px;
  598. border: none;
  599. cursor: pointer;
  600. }
  601. .btn-close {
  602. color: #313131;
  603. background-color: gray;
  604. }
  605. .btn-confirm {
  606. color: #fff;
  607. background-color: #0056a0;
  608. }
  609. .bodyRow {
  610. display: flex;
  611. justify-content: flex-start;
  612. align-items: center;
  613. padding: 4px;
  614. }
  615. .bodyRow span {
  616. width: 80px;
  617. margin: 10px;
  618. }
  619. .bodyRow select {
  620. width: 120px;
  621. }
  622. .bodyRow input {
  623. width: 112px;
  624. }
  625. .longInput input {
  626. width: 476px;
  627. }
  628. .bodyRow select,
  629. input {
  630. padding: 2px;
  631. }
  632. .contentCol1 {
  633. display: flex;
  634. justify-content: flex-start;
  635. align-items: center;
  636. }
  637. .contentCol1 span {
  638. width: 80px;
  639. margin: 10px;
  640. }
  641. .contentCol1 div {
  642. width: 120px;
  643. }
  644. .contentCol2 {
  645. display: flex;
  646. justify-content: flex-end;
  647. align-items: center;
  648. width: 363px;
  649. }
  650. .timeWidth input {
  651. width: 150px;
  652. }
  653. </style>