| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529 |
- <template>
- <div class="modal-backdrop">
- <div class="modal">
- <div class="modal-header">
- <span>新增</span>
- </div>
- <div class="modal-body">
- <div class="bodyRow">
- <span>资料名称</span>
- <div>{{ fileName }}</div>
- </div>
- <div class="bodyRow timeWidth">
- <span>发布时间</span
- ><input
- type="date"
- placeholder="选择时间"
- :max="localDay"
- v-model="ziliaoTime"
- />
- </div>
- <div class="bodyRow">
- <div class="contentCol1">
- <span>涉及车型</span
- ><select v-model="carTypeValue">
- <option
- v-for="(item, index) in carType"
- :key="index"
- :value="item.typeName"
- >
- {{ item.typeName || "123" }}
- </option>
- </select>
- </div>
- </div>
- <div class="bodyRow">
- <div class="contentCol1">
- <span>发布渠道</span>
- <select
- name=""
- id=""
- v-model="releaseC"
- @change="chooseChannel($event)"
- >
- <option v-for="(item, index) in releaseChannel" :key="index">
- {{ item.platformName || "-" }}
- </option>
- </select>
- </div>
- <div class="contentCol2">
- <span>平台版块</span>
- <div v-if="releaseC !== '其它'">
- <select name="" id="" v-model="releaseP">
- <option v-for="(item, index) in releasePlate" :key="index">
- {{ item.platformName || "-" }}
- </option>
- </select>
- </div>
- <div v-else>
- <input type="text" v-model="releaseP" />
- </div>
- </div>
- </div>
- <div class="bodyRow">
- <div class="contentCol1">
- <span>稿件类别</span>
- <select name="" id="" v-model="contentName1">
- <option v-for="(item, index) in content1" :key="index">
- {{ item.dictName }}
- </option>
- </select>
- </div>
- <div class="contentCol2">
- <span>内容分类</span
- ><select name="" id="" v-model="contentName2">
- <option v-for="(item, index) in content2" :key="index">
- {{ item.dictName || "-" }}
- </option>
- </select>
- </div>
- </div>
- <div class="bodyRow">
- <div class="contentCol1">
- <span>阅读量</span>
- <input type="number" placeholder="" min="0" v-model="readCount" />
- </div>
- <div class="contentCol2">
- <span>点赞</span>
- <input type="number" placeholder="" min="0" v-model="goodCount" />
- </div>
- </div>
- <div class="bodyRow">
- <div class="contentCol1">
- <span>评论</span>
- <input type="number" placeholder="" min="0" v-model="bbsCount" />
- </div>
- <div class="contentCol2">
- <span>在看/转发</span>
- <input
- type="number"
- placeholder=""
- min="0"
- v-model="lookingCount"
- />
- </div>
- </div>
- <div class="bodyRow longInput">
- <span>标题</span>
- <input type="text" placeholder="文章标题" v-model="mediaTitle" />
- </div>
- <div class="bodyRow longInput">
- <span>链接</span>
- <input type="text" placeholder="文章发布地址" v-model="mediaUrl" />
- </div>
- </div>
- <div class="modal-footer">
- <!-- <button type="button" class="btn-confirm" @click="confirm">确认</button> -->
- <button type="button" class="btn-confirm" @click="testUrl()">
- 确认
- </button>
- <button type="button" class="btn-close" @click="closeSelf">取消</button>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: "Modal",
- props: {
- fileName: {
- type: String,
- default: "",
- },
- ziliaoId: {
- type: String,
- default: "",
- },
- userId: {
- type: String,
- default: "",
- },
- },
- data() {
- return {
- ziliaoTime: "",
- carTypeValue: "1",
- carType: [],
- releaseC: "", //'发布渠道',
- releaseChannel: [], // 发布渠道列表
- releaseP: "", //'平台版块',
- releasePlate: [], // 平台版块
- contentName1: "", //"稿件类别",
- content1: [],
- contentName2: "", //'内容分类',
- content2: [],
- readCount: 0,
- goodCount: 0,
- bbsCount: 0,
- lookingCount: 0,
- mediaTitle: "", //'文章标题',
- mediaUrl: "",
- dictList: [],
- initParentId: "",
- localDay: "",
- noEditFlag: false,
- };
- },
- methods: {
- // 改变发布渠道
- chooseChannel: function (e) {
- let index = e.target.options.selectedIndex;
- let req = {
- parentId: this.releaseChannel[index].id,
- };
- this.channelType(req);
- },
- // 确认
- testUrl: function () {
- var regex = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?$/;
- let flag = regex.test(this.mediaUrl);
- if (flag) {
- this.edit();
- } else {
- alert("链接输入有误!\n示例:https://www.baidu.com");
- }
- },
- // 取消
- closeSelf: function () {
- this.$emit("closeme");
- },
- // 判断非空
- beforeEdit: function () {
- this.releaseP = (this.releaseP || "").replace(/\s/g, "");
- this.mediaTitle = (this.mediaTitle || "").replace(/\s/g, "");
- if (!this.ziliaoTime) {
- this.noEditFlag = true;
- alert("发布时间不能为空");
- return;
- }
- if (!this.carTypeValue) {
- this.noEditFlag = true;
- alert("请选择车型");
- return;
- }
- if (!this.releaseC) {
- this.noEditFlag = true;
- alert("请选择发布渠道");
- return;
- }
- if (!this.releaseP) {
- this.noEditFlag = true;
- alert("请选择平台版块");
- return;
- }
- if (!this.contentName1) {
- this.noEditFlag = true;
- alert("请选择稿件类别");
- return;
- }
- if (!this.contentName2) {
- this.noEditFlag = true;
- alert("请选择内容分类");
- return;
- }
- if (!this.readCount || this.readCount < 0) {
- this.noEditFlag = true;
- alert("请填写阅读量");
- return;
- }
- if (!this.goodCount || this.goodCount < 0) {
- this.noEditFlag = true;
- alert("请填写点赞量");
- return;
- }
- if (!this.bbsCount || this.bbsCount < 0) {
- this.noEditFlag = true;
- alert("请填写评论量");
- return;
- }
- if (!this.lookingCount || this.lookingCount < 0) {
- this.noEditFlag = true;
- alert("请填写正确的在看/转发");
- return;
- }
- if (!this.mediaTitle) {
- this.noEditFlag = true;
- alert("标题不能为空");
- return;
- }
- if (!this.mediaUrl) {
- this.noEditFlag = true;
- alert("链接不能为空");
- return;
- }
- },
- edit() {
- this.noEditFlag = false;
- this.beforeEdit();
- if (!this.noEditFlag) {
- //当前月份
- let date = new Date();
- let m = date.getMonth() + 1;
- let y = date.getFullYear();
- let d = y + "/" + m;
- let config = {
- url: "",
- data: {
- month: d,
- dealerId: this.userId,
- dataId: this.ziliaoId,
- informationName: this.fileName,
- releaseTime: this.ziliaoTime,
- carType: this.carTypeValue,
- releaseMedia: this.releaseC,
- releasePlate: this.releaseP,
- draftGenre: this.contentName1,
- contentClass: this.contentName2,
- articleTitle: this.mediaTitle,
- articleLink: this.mediaUrl,
- readCount: this.readCount,
- goodCount: this.goodCount,
- bbsCount: this.bbsCount,
- lookingCount: this.lookingCount,
- },
- };
- this.$emit("add_feedback", config);
- this.closeSelf();
- }
- },
- // 获取当前的月份
- getLocalMonth: function () {
- let data = new Date();
- let year = data.getFullYear();
- let month = data.getMonth() + 1;
- let day = data.getDate();
- if (month < 10) {
- month = "0" + month;
- } else {
- month = month + "";
- }
- this.localDay = year + "-" + month + "-" + day;
- },
- getCarType: function () {
- this.$http({
- method: "post",
- url: "/base/carTypeManager/selectCarTypePage",
- data: {},
- })
- .then((res) => {
- if (res.data && res.data.code === 200) {
- this.carType = res.data.data;
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- channelType: function (data) {
- return new Promise((resolve, reject) => {
- this.$http({
- url: "/base/publishPlatformManager/selectPublishPlatformPage",
- method: "post",
- data,
- })
- .then((res) => {
- this.releasePlate = [];
- if (res.data.code === 200) {
- if (!data) {
- this.releaseChannel = res.data.data;
- } else {
- this.releasePlate = res.data.data;
- }
- }
- resolve();
- })
- .catch((err) => {
- console.log(err);
- reject();
- });
- });
- },
- // 获取内容分类、媒体平台、常用参数接口的标识,再调接口时需要用到
- selectSysDataDictList: function () {
- return new Promise((resolve, reject) => {
- this.$http({
- method: "post",
- url: "/sys/dataDict/selectSysDataDictList",
- data: {},
- })
- .then((res) => {
- if (res.data && res.data.code === 200) {
- this.dictList = res.data.data;
- resolve();
- }
- })
- .catch((err) => {
- console.log(err);
- reject();
- });
- });
- },
- getContent1: function () {
- this.$http({
- method: "post",
- url: "/sys/dataDict/selectSysDataDictPage",
- data: {
- dictCode: this.dictList[1]["dictCode"],
- parentId: this.dictList[1]["id"],
- },
- })
- .then((res) => {
- if (res.data && res.data.code === 200) {
- this.content1 = res.data.data;
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- getContent2: function () {
- this.$http({
- method: "post",
- url: "/sys/dataDict/selectSysDataDictPage",
- data: {
- dictCode: this.dictList[2]["dictCode"],
- parentId: this.dictList[2]["id"],
- },
- })
- .then((res) => {
- if (res.data && res.data.code === 200) {
- this.content2 = res.data.data;
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- },
- mounted() {
- this.getLocalMonth();
- this.getCarType();
- this.channelType();
- this.selectSysDataDictList().then(() => {
- this.getContent1();
- this.getContent2();
- });
- },
- };
- </script>
- <style>
- .modal-backdrop {
- position: fixed;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- background-color: #7d9191;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .modal {
- background-color: #eeeeee;
- box-shadow: 2px 2px 20px 1px;
- overflow-x: auto;
- display: flex;
- flex-direction: column;
- border-radius: 0px;
- width: 1030px;
- }
- .modal-header {
- border-bottom: 1px solid #eee;
- color: #313131;
- justify-content: space-between;
- padding: 15px;
- display: flex;
- border-bottom: 1px solid #e3e3e3;
- }
- .modal-header span {
- font-size: 16px;
- font-weight: bold;
- }
- .modal-footer {
- border-top: 1px solid #eee;
- justify-content: center;
- padding: 15px;
- display: flex;
- }
- .modal-footer button {
- width: 90px;
- margin-left: 0px;
- }
- .modal-footer button:nth-child(1) {
- margin-right: 80px;
- }
- .modal-body {
- position: relative;
- padding: 20px 120px 20px 180px;
- }
- .modal-body span,
- select,
- input,
- div {
- font-size: 14px;
- }
- .btn-close,
- .btn-confirm {
- border-radius: 8px;
- margin-left: 16px;
- width: 56px;
- height: 36px;
- border: none;
- cursor: pointer;
- }
- .btn-close {
- color: #313131;
- background-color: gray;
- }
- .btn-confirm {
- color: #fff;
- background-color: #0056a0;
- }
- .bodyRow {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- padding: 4px;
- }
- .bodyRow span {
- width: 80px;
- margin: 10px;
- }
- .bodyRow select {
- width: 120px;
- }
- .bodyRow input {
- width: 112px;
- }
- .longInput input {
- width: 476px;
- }
- .bodyRow select,
- input {
- padding: 2px;
- }
- .contentCol1 {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- }
- .contentCol1 span {
- width: 80px;
- margin: 10px;
- }
- .contentCol1 div {
- width: 120px;
- }
- .contentCol2 {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- width: 363px;
- }
- .timeWidth input {
- width: 150px;
- }
- </style>
|