|
|
@@ -10,7 +10,7 @@
|
|
|
@focus="hideTip"
|
|
|
@blur="checkName()"
|
|
|
/>
|
|
|
- <p v-show="tipFlag">资料名称不能重复,请重新输入</p>
|
|
|
+ <p v-show="tipFlag">{{ tipText }}</p>
|
|
|
</div>
|
|
|
<div class="inforDes">
|
|
|
<span>资料描述</span
|
|
|
@@ -71,7 +71,7 @@
|
|
|
<option
|
|
|
v-for="(dlr, index) in dlrList"
|
|
|
:key="index"
|
|
|
- :value="dlr"
|
|
|
+ :value="dlr.dlrCode || dlr.dlrName"
|
|
|
></option>
|
|
|
</datalist>
|
|
|
<button @click.prevent="addBySelf">添加</button>
|
|
|
@@ -153,21 +153,23 @@ export default {
|
|
|
watch: {},
|
|
|
data() {
|
|
|
return {
|
|
|
+ allDataNameList: [],
|
|
|
tipFlag: false, // 是否展示提示
|
|
|
+ tipText: "资料名称不能重复,请重新输入",
|
|
|
inforName: "",
|
|
|
inforDes: "",
|
|
|
materialTime: "",
|
|
|
scope: "1", //1为共通 , 0为部分
|
|
|
checkedBoxList: [], // 多选框选中的值
|
|
|
addByCustomize: "",
|
|
|
- dlrList: ["北京博瑞1", "北京博瑞2", "北京博瑞3"], // 自定义添加
|
|
|
+ dlrList: [], // 自定义添加
|
|
|
addGroupList: [], // 添加的小组
|
|
|
addFlag: [true, true, true, true, true, true], // 长度等于groupList.length
|
|
|
optionFlag: false, // 是否展示按小组添加的选择栏
|
|
|
fileDes: [], // 上传的文件名
|
|
|
file: "", //上传的文件
|
|
|
// 表格配置
|
|
|
- sum: 240, // 一共有多少条数据
|
|
|
+ sum: 0, // 一共有多少条数据
|
|
|
pageSize: 20, // 每页展示的数据
|
|
|
currentPage: 1,
|
|
|
areaList: AREASLIST, // 按区域添加
|
|
|
@@ -189,12 +191,20 @@ export default {
|
|
|
methods: {
|
|
|
// 检查名字是否重复 失去焦点判断
|
|
|
checkName: function () {
|
|
|
- if (this.inforName == 1) {
|
|
|
+ let include = this.allDataNameList.indexOf(this.inforName);
|
|
|
+ if (!this.inforName) {
|
|
|
+ this.tipText = "资料名不能为空";
|
|
|
this.tipFlag = true;
|
|
|
+ return;
|
|
|
+ } else if (include > 0) {
|
|
|
+ this.tipText = "资料名称不能重复,请重新输入";
|
|
|
+ this.tipFlag = true;
|
|
|
+ return;
|
|
|
}
|
|
|
},
|
|
|
// 名字不重复,隐藏提示
|
|
|
hideTip: function () {
|
|
|
+ this.tipText = "资料名称不能重复,请重新输入";
|
|
|
this.tipFlag = false;
|
|
|
},
|
|
|
// 素材时间变化
|
|
|
@@ -213,13 +223,13 @@ export default {
|
|
|
// 保证多选框全区和其他的多选框互斥
|
|
|
clickCheckbox(i) {
|
|
|
let list = this.checkedBoxList;
|
|
|
- let include = list.indexOf('all');
|
|
|
- if(i===0) {
|
|
|
+ let include = list.indexOf("all");
|
|
|
+ if (i === 0) {
|
|
|
this.checkedBoxList = [];
|
|
|
- return
|
|
|
- }
|
|
|
- if (include >= 0){
|
|
|
- this.checkedBoxList.splice(0, 1)
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (include >= 0) {
|
|
|
+ this.checkedBoxList.splice(0, 1);
|
|
|
}
|
|
|
},
|
|
|
// 点击按区域添加button
|
|
|
@@ -229,6 +239,11 @@ export default {
|
|
|
// 自定义添加
|
|
|
addBySelf: function () {
|
|
|
console.log(this.addByCustomize);
|
|
|
+ let data = {
|
|
|
+ dlrCode: this.addByCustomize,
|
|
|
+ };
|
|
|
+ this.getDlrData(data);
|
|
|
+ this.getAllDlr(data);
|
|
|
},
|
|
|
// 按小组添加,增加小组
|
|
|
addGroup: function (index) {
|
|
|
@@ -277,43 +292,54 @@ export default {
|
|
|
this.currentPage = this.totalPage;
|
|
|
break;
|
|
|
}
|
|
|
- console.log(this.currentPage);
|
|
|
this.getDlrData(this.currentPage);
|
|
|
},
|
|
|
// 点击提交,检查名字是否重复,获取数据
|
|
|
submit: function () {
|
|
|
this.checkName();
|
|
|
- // if(!this.inforName){
|
|
|
- // alert('资料名称不能为空');
|
|
|
- // return false
|
|
|
- // }
|
|
|
- // if(!this.inforDes){
|
|
|
- // alert('资料描述不能为空');
|
|
|
- // return false
|
|
|
- // }
|
|
|
- // if(!this.inforName){
|
|
|
- // alert('资料名称不能为空');
|
|
|
- // return false
|
|
|
- // }
|
|
|
if (!this.tipFlag) {
|
|
|
- console.log(this.inforName);
|
|
|
- console.log(this.inforDes);
|
|
|
- console.log(this.materialTime);
|
|
|
- console.log(this.scope);
|
|
|
- console.log(this.tableData);
|
|
|
- const file = document.getElementById("fileInput").value;
|
|
|
- console.log(file);
|
|
|
- // console.log(document.getElementById('fileInput').files[0].name);
|
|
|
+ if (!this.inforDes) {
|
|
|
+ alert("资料描述不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.materialTime) {
|
|
|
+ alert("素材事件不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.file) {
|
|
|
+ alert("请导入附件");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.submitRequest();
|
|
|
}
|
|
|
- this.submitRequest();
|
|
|
+ this.submitRequest();
|
|
|
+ },
|
|
|
+ // 获取文件名
|
|
|
+ getFileInfo: function (event) {
|
|
|
+ this.file = event.target.files;
|
|
|
+ this.fileDes = [];
|
|
|
+ this.file.forEach((item) => {
|
|
|
+ this.fileDes.push(item.name);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取当前的月份
|
|
|
+ getLocalMonth: function () {
|
|
|
+ let data = new Date();
|
|
|
+ let year = data.getFullYear();
|
|
|
+ let month = data.getMonth() + 1;
|
|
|
+ if (month < 10) {
|
|
|
+ month = "0" + month;
|
|
|
+ } else {
|
|
|
+ month = month + "";
|
|
|
+ }
|
|
|
+ this.localMonth = year + "-" + month;
|
|
|
},
|
|
|
// 提交接口
|
|
|
submitRequest: function () {
|
|
|
let paramData = new FormData();
|
|
|
this.file.forEach((item) => {
|
|
|
- console.log(item , 1111111);
|
|
|
- paramData.append("file", this.item);
|
|
|
- })
|
|
|
+ paramData.append("file", item);
|
|
|
+ });
|
|
|
paramData.append("dataName", this.inforName);
|
|
|
paramData.append("dataDesc", this.inforDes);
|
|
|
paramData.append("sourceTime", this.materialTime);
|
|
|
@@ -322,76 +348,99 @@ export default {
|
|
|
this.$http
|
|
|
.uploadFile("/firmsUpload", paramData)
|
|
|
.then((res) => {
|
|
|
- console.log(res);
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ alert("上传成功");
|
|
|
+ } else {
|
|
|
+ alert("上传失败,请重试");
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ alert("上传失败,请重试");
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取所有资料名称
|
|
|
+ getAllDataName: function () {
|
|
|
+ this.$http({
|
|
|
+ method: "post",
|
|
|
+ url: "/firmsUploadList",
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ (this.allDataNameList = []),
|
|
|
+ res.data.data.forEach((item) => {
|
|
|
+ this.allDataNameList.push(item.informationName);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
console.log(err);
|
|
|
});
|
|
|
},
|
|
|
// 获取所有经销商信息接口
|
|
|
- getAllDlr: function () {
|
|
|
+ getAllDlr: function (data = {}) {
|
|
|
this.$http({
|
|
|
- methods: "post",
|
|
|
+ method: "post",
|
|
|
url: "/sys/agent/selectAgentInfoList",
|
|
|
- data: {},
|
|
|
+ data: data,
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- console.log(res);
|
|
|
- this.dlrList = res.data;
|
|
|
- // this.tableData = this.tableData // 获取tableData的值
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ this.dlrList = [];
|
|
|
+ this.AllDlr = res.data.data;
|
|
|
+ let resData = JSON.parse(JSON.stringify(res.data.data));
|
|
|
+ resData.forEach((item) => {
|
|
|
+ // 获取自定义下拉框的值
|
|
|
+ if (item.dlrCode || item.dlrName) {
|
|
|
+ this.dlrList.push({
|
|
|
+ dlrCode: item.dlrCode,
|
|
|
+ });
|
|
|
+ this.dlrList.push({
|
|
|
+ dlrName: item.dlrName,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
console.log(err);
|
|
|
});
|
|
|
},
|
|
|
// 分页获取所有进销商信息接口
|
|
|
- getDlrData: function (page) {
|
|
|
+ getDlrData: function (data = {}) {
|
|
|
this.$http({
|
|
|
- methods: "post",
|
|
|
+ method: "post",
|
|
|
url: "/sys/agent/selectAgentInfoPage",
|
|
|
- data: {
|
|
|
- page: page
|
|
|
- },
|
|
|
+ data: data,
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- console.log(res);
|
|
|
- this.tableData = [
|
|
|
- { name: "北京博瑞", code: "L020", area: "东区" },
|
|
|
- { name: "a", code: "a", area: "N" },
|
|
|
- { name: "a", code: "a", area: "N" },
|
|
|
- ];
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ this.tableData = res.data.data;
|
|
|
+ this.sum = res.data.count;
|
|
|
+ } else {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
console.log(err);
|
|
|
});
|
|
|
},
|
|
|
- // 获取文件名
|
|
|
- getFileInfo: function (event) {
|
|
|
- this.file = event.target.files;
|
|
|
- this.fileDes = [];
|
|
|
- this.file.forEach((item) => {
|
|
|
- this.fileDes.push(item.name);
|
|
|
- })
|
|
|
- },
|
|
|
- // 获取当前的月份
|
|
|
- getLocalMonth: function () {
|
|
|
- let data = new Date();
|
|
|
- let year = data.getFullYear();
|
|
|
- let month = data.getMonth() + 1;
|
|
|
- if (month < 10) {
|
|
|
- month = "0" + month;
|
|
|
- } else {
|
|
|
- month = month + "";
|
|
|
- }
|
|
|
- this.localMonth = year + "-" + month;
|
|
|
- },
|
|
|
},
|
|
|
mounted() {
|
|
|
this.getLocalMonth();
|
|
|
},
|
|
|
created() {
|
|
|
- this.getAllDlr(); // 放到点开进销商范围
|
|
|
- this.getDlrData(1);
|
|
|
+ // 获取所有经销商信息
|
|
|
+ this.getAllDlr();
|
|
|
+ // 获取第一页经销商信息
|
|
|
+ this.getDlrData();
|
|
|
+ // 获取所有的资料名称
|
|
|
+ this.getAllDataName();
|
|
|
},
|
|
|
};
|
|
|
</script>
|