|
|
@@ -3,7 +3,15 @@
|
|
|
<form>
|
|
|
<div class="Line Line1">
|
|
|
<span>标题:</span>
|
|
|
- <input type="text" v-model="contentParam.title"/>
|
|
|
+ <input
|
|
|
+ type="text"
|
|
|
+ v-model="contentParam.title"
|
|
|
+ @focus="hideTip"
|
|
|
+ @blur="checkName"
|
|
|
+ />
|
|
|
+ <p v-show="tipFlag" style="margin-left: 88px; color: red">
|
|
|
+ {{ tipText }}
|
|
|
+ </p>
|
|
|
</div>
|
|
|
<div class="Line Line2">
|
|
|
<span>类型:</span>
|
|
|
@@ -39,16 +47,16 @@
|
|
|
<div style="clear: both; display: block"></div>
|
|
|
</div>
|
|
|
|
|
|
-
|
|
|
<div class="uploadFile">
|
|
|
<p class="title">附件:</p>
|
|
|
- <label for="fileInput" @change="getFileInfo($event)">添加附件
|
|
|
- <input type="file" name="fileName" id="fileInput" multiple/>
|
|
|
+ <label for="fileInput" @change="getFileInfo($event)"
|
|
|
+ >添加附件
|
|
|
+ <input type="file" name="fileName" id="fileInput" multiple />
|
|
|
</label>
|
|
|
<div class="fileDes">
|
|
|
- <p v-for="(item, index) in contentParam.files" :key="index"
|
|
|
- >{{ item.file_name || item.name}}
|
|
|
- <span class="deleteFile" @click="deleteFile(index,item)">×</span>
|
|
|
+ <p v-for="(item, index) in contentParam.files" :key="index">
|
|
|
+ {{ item.file_name || item.name }}
|
|
|
+ <span class="deleteFile" @click="deleteFile(index, item)">×</span>
|
|
|
</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -58,9 +66,9 @@
|
|
|
<button @click="backToPre()">返回</button>
|
|
|
</div>
|
|
|
<TipModal
|
|
|
- :tipFlag="tipModalFlag"
|
|
|
- :tipText="tipModalText"
|
|
|
- @close_tip_modal="closeTipModal"
|
|
|
+ :tipFlag="tipModalFlag"
|
|
|
+ :tipText="tipModalText"
|
|
|
+ @close_tip_modal="closeTipModal"
|
|
|
/>
|
|
|
<Loading v-if="uploading"></Loading>
|
|
|
</div>
|
|
|
@@ -111,17 +119,20 @@ import {
|
|
|
// CodeView,
|
|
|
} from "element-tiptap";
|
|
|
import TipModal from "../../../components/TipModal";
|
|
|
-import Loading from "../../data/components/UploadLoading"
|
|
|
+import Loading from "../../data/components/UploadLoading";
|
|
|
import helpButton from "../custom_extensions/helpButton/index";
|
|
|
import CodeView from "../custom_extensions/CodeView/index";
|
|
|
import { php_url } from "../../../config/env";
|
|
|
import axiosPhp from "axios";
|
|
|
export default {
|
|
|
- components: {TipModal,Loading},
|
|
|
+ components: { TipModal, Loading },
|
|
|
data() {
|
|
|
return {
|
|
|
- noticeTitle:'',
|
|
|
+ tipFlag: false,
|
|
|
+ tipText: "",
|
|
|
+ noticeTitle: "",
|
|
|
InfoType: "",
|
|
|
+ title: this.$route.query && this.$route.query.title,
|
|
|
areaList: ["全区", "北区", "南区", "东区"], // 按区域添加
|
|
|
extensions: [
|
|
|
// new Preview(),
|
|
|
@@ -167,67 +178,71 @@ export default {
|
|
|
new History(),
|
|
|
new helpButton({ bubble: false }),
|
|
|
],
|
|
|
- content:'',
|
|
|
- unifiedUrl:'/lexus_php/api/',
|
|
|
+ content: "",
|
|
|
+ unifiedUrl: "/lexus_php/api/",
|
|
|
fileDes: [], // 上传的文件名,
|
|
|
- file:[],
|
|
|
+ file: [],
|
|
|
tipModalFlag: false,
|
|
|
tipModalText: "",
|
|
|
uploading: false,
|
|
|
- contentParam:{
|
|
|
- },
|
|
|
- noticeId:'',
|
|
|
- delFileIds:[],
|
|
|
- editFileLength:''
|
|
|
+ contentParam: {},
|
|
|
+ noticeId: "",
|
|
|
+ delFileIds: [],
|
|
|
+ editFileLength: "",
|
|
|
+ allDataNameList: [],
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
- addNotice(id){
|
|
|
- let requestURL,paramData;
|
|
|
- if(id){ //编辑
|
|
|
- requestURL = 'notice_update.php';
|
|
|
- paramData = new FormData();
|
|
|
- paramData.append("title", this.contentParam.title);
|
|
|
- paramData.append("area", this.contentParam.area);
|
|
|
- paramData.append("content", this.contentParam.content);
|
|
|
- paramData.append("id", id);
|
|
|
- console.log(this.delFileIds.length);
|
|
|
- if(this.delFileIds.length){
|
|
|
- let delFileStr = this.delFileIds.join(',');
|
|
|
- paramData.append("del_file_ids", delFileStr);
|
|
|
- }
|
|
|
- if(this.contentParam.files.length === 0){
|
|
|
- paramData.append("file_num", '0');
|
|
|
- }else {
|
|
|
- let count = 0;
|
|
|
- let len = this.file.length;
|
|
|
- this.file.forEach((item) => {
|
|
|
- count++;
|
|
|
- paramData.append("file" + count, item);
|
|
|
- });
|
|
|
- paramData.append("file_num", len);
|
|
|
- }
|
|
|
- }
|
|
|
- else { //新增
|
|
|
- requestURL = 'notice_add.php';
|
|
|
- paramData = new FormData();
|
|
|
- paramData.append("title", this.contentParam.title);
|
|
|
- paramData.append("area", this.contentParam.area);
|
|
|
- paramData.append("content", this.contentParam.content);
|
|
|
- if(this.file.length === 0){
|
|
|
- paramData.append("file_num", '0');
|
|
|
- }else {
|
|
|
- let count = 0;
|
|
|
- let len = this.file.length;
|
|
|
- this.file.forEach((item) => {
|
|
|
- count++;
|
|
|
- paramData.append("file" + count, item);
|
|
|
- });
|
|
|
- paramData.append("file_num", len);
|
|
|
+ addNotice(id) {
|
|
|
+ let requestURL, paramData;
|
|
|
+ this.checkName();
|
|
|
+ if (!this.tipFlag) {
|
|
|
+ if (id) {
|
|
|
+ //编辑
|
|
|
+ requestURL = "notice_update.php";
|
|
|
+ paramData = new FormData();
|
|
|
+ paramData.append("title", this.contentParam.title);
|
|
|
+ paramData.append("area", this.contentParam.area);
|
|
|
+ paramData.append("content", this.contentParam.content);
|
|
|
+ paramData.append("id", id);
|
|
|
+ console.log(this.delFileIds);
|
|
|
+ console.log(this.delFileIds.length);
|
|
|
+ if (this.delFileIds.length) {
|
|
|
+ let delFileStr = this.delFileIds.join(",");
|
|
|
+ paramData.append("del_file_ids", delFileStr);
|
|
|
+ }
|
|
|
+ if (this.contentParam.files && this.contentParam.files.length === 0) {
|
|
|
+ paramData.append("file_num", "0");
|
|
|
+ } else {
|
|
|
+ let count = 0;
|
|
|
+ let len = this.file.length;
|
|
|
+ this.file.forEach((item) => {
|
|
|
+ count++;
|
|
|
+ paramData.append("file" + count, item);
|
|
|
+ });
|
|
|
+ paramData.append("file_num", len);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //新增
|
|
|
+ requestURL = "notice_add.php";
|
|
|
+ paramData = new FormData();
|
|
|
+ paramData.append("title", this.contentParam.title);
|
|
|
+ paramData.append("area", this.contentParam.area);
|
|
|
+ paramData.append("content", this.contentParam.content);
|
|
|
+ if (this.file.length === 0) {
|
|
|
+ paramData.append("file_num", "0");
|
|
|
+ } else {
|
|
|
+ let count = 0;
|
|
|
+ let len = this.file.length;
|
|
|
+ this.file.forEach((item) => {
|
|
|
+ count++;
|
|
|
+ paramData.append("file" + count, item);
|
|
|
+ });
|
|
|
+ paramData.append("file_num", len);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- this.uploading = true;
|
|
|
+ this.uploading = true;
|
|
|
axiosPhp({
|
|
|
url: php_url + this.unifiedUrl + requestURL,
|
|
|
method: "post",
|
|
|
@@ -240,20 +255,20 @@ export default {
|
|
|
.then((res) => {
|
|
|
this.uploading = false;
|
|
|
if (res.data.code === 200) {
|
|
|
- this.tipModalFlag = true;
|
|
|
- if(id){
|
|
|
+ this.tipModalFlag = true;
|
|
|
+ if (id) {
|
|
|
this.tipModalText = "更新成功!";
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
this.tipModalText = "新增成功!";
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
alert(res.data.message);
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
alert(err);
|
|
|
});
|
|
|
-
|
|
|
+ }
|
|
|
},
|
|
|
// 关闭提示框
|
|
|
closeTipModal: function () {
|
|
|
@@ -269,13 +284,12 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
// 删除文件
|
|
|
- deleteFile: function(i,item) {
|
|
|
- if(this.noticeId && (this.editFileLength > this.delFileIds.length)){
|
|
|
+ deleteFile: function (i, item) {
|
|
|
+ if (this.noticeId && this.editFileLength > this.delFileIds.length) {
|
|
|
this.delFileIds.push(item.file_id);
|
|
|
}
|
|
|
this.file.splice(i, 1);
|
|
|
this.contentParam.files.splice(i, 1);
|
|
|
- console.log(this.delFileIds.length,this.contentParam.files.length,this.editFileLength)
|
|
|
},
|
|
|
// 保证多选框东区和其他的多选框互斥
|
|
|
clickCheckbox(i) {
|
|
|
@@ -295,12 +309,62 @@ export default {
|
|
|
query: {},
|
|
|
});
|
|
|
},
|
|
|
+ // 转地区的格式
|
|
|
+ areaToList() {
|
|
|
+ this.contentParam = this.$route.query || {};
|
|
|
+ const areaList = this.contentParam.area.split(",");
|
|
|
+ this.contentParam.area = areaList;
|
|
|
+ },
|
|
|
+ getDataList: function (data = {}) {
|
|
|
+ axiosPhp({
|
|
|
+ method: "post",
|
|
|
+ url: php_url + this.unifiedUrl + "notice_list.php",
|
|
|
+ data,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ res.data.data.forEach((element) => {
|
|
|
+ if(element.title !==this.title){
|
|
|
+ this.allDataNameList.push(element.title);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 名字不重复,隐藏提示
|
|
|
+ hideTip: function () {
|
|
|
+ this.tipText = "资料名称不能重复,请重新输入";
|
|
|
+ this.tipFlag = false;
|
|
|
+ },
|
|
|
+ // 检查名字是否重复 失去焦点判断
|
|
|
+ checkName: function () {
|
|
|
+ // 去前后空格
|
|
|
+ this.contentParam.title = this.contentParam.title.replace(
|
|
|
+ /(^\s*)|(\s*$)/g,
|
|
|
+ ""
|
|
|
+ );
|
|
|
+ let include = this.allDataNameList.indexOf(this.contentParam.title);
|
|
|
+ if (!this.contentParam.title) {
|
|
|
+ this.tipText = "资料名不能为空";
|
|
|
+ this.tipFlag = true;
|
|
|
+ return;
|
|
|
+ } else if (include >= 0) {
|
|
|
+ this.tipText = "资料名称不能重复,请重新输入";
|
|
|
+ this.tipFlag = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.contentParam = this.$route.query;
|
|
|
+ this.getDataList();
|
|
|
+ this.areaToList();
|
|
|
this.noticeId = this.contentParam.id;
|
|
|
- this.editFileLength = this.contentParam.files.length;
|
|
|
- console.log(this.contentParam)
|
|
|
+ if (this.contentParam.files) {
|
|
|
+ this.editFileLength = this.contentParam.files.length;
|
|
|
+ }
|
|
|
},
|
|
|
created() {},
|
|
|
};
|
|
|
@@ -395,7 +459,7 @@ export default {
|
|
|
display: flex;
|
|
|
margin-top: 35px;
|
|
|
min-height: 100px;
|
|
|
- .title{
|
|
|
+ .title {
|
|
|
margin-right: 8px;
|
|
|
height: 20px;
|
|
|
line-height: 20px;
|