|
|
@@ -20,167 +20,254 @@
|
|
|
<script src="{{mix('js/queryForm/queryForm.js')}}"></script>
|
|
|
|
|
|
<script>
|
|
|
- new Vue({
|
|
|
+ let demand_vue = new Vue({
|
|
|
el: '#list',
|
|
|
data: {
|
|
|
demands: {!! $demands->toJson() !!}['data'],
|
|
|
status: [
|
|
|
- {name: 0, value: '未处理'}, {name: 1, value: '处理中'} ,{name: 2, value: '已处理'},
|
|
|
+ {name: 0, value: '未处理'}, {name: 1, value: '处理中'}, {name: 2, value: '已处理'},
|
|
|
],
|
|
|
types: [
|
|
|
{name: 0, value: '需求'}, {name: 1, value: '问题'}
|
|
|
],
|
|
|
selectTr: null,
|
|
|
- uploadError:null,
|
|
|
- selectDemand:null,
|
|
|
- selectIndex:null,
|
|
|
+ uploadError: null,
|
|
|
+ selectDemand: null,
|
|
|
+ selectIndex: null,
|
|
|
+ imgs: '',
|
|
|
},
|
|
|
created() {
|
|
|
let that = this;
|
|
|
- this.demands.forEach(function (item,index,self){
|
|
|
- self[index]['status'] = that.status[item['status']]['value'] ?? '';
|
|
|
- self[index]['type'] = that.types[item['type']]['value'] ?? '';
|
|
|
+ this.demands.forEach(function (item, index, self) {
|
|
|
+ that.initDemand(self[index]);
|
|
|
});
|
|
|
},
|
|
|
- mounted(){
|
|
|
+ mounted() {
|
|
|
+ this.imgs = Array.from(document.getElementById('list').querySelectorAll('img'));
|
|
|
+ this.lazy();
|
|
|
+ if (this.imgs && this.imgs.length > 0) {
|
|
|
+ window.addEventListener('scroll', this.lazy)
|
|
|
+ }
|
|
|
$('#list').removeClass('d-none');
|
|
|
let data = [
|
|
|
[
|
|
|
- {name:'created_at_start',type:'time',tip:'创建开始时间'},
|
|
|
- {name:'created_at_end',type:'time',tip:'创建结束时间'},
|
|
|
- {name:'type',type:'select',data:this.types,placeholder:'类型'},
|
|
|
+ {name: 'created_at_start', type: 'time', tip: '创建开始时间'},
|
|
|
+ {name: 'created_at_end', type: 'time', tip: '创建结束时间'},
|
|
|
+ {name: 'type', type: 'select', data: this.types, placeholder: '类型'},
|
|
|
]
|
|
|
];
|
|
|
- let form=new query({
|
|
|
- el:"#form_div",
|
|
|
- condition:data,
|
|
|
+ let form = new query({
|
|
|
+ el: "#form_div",
|
|
|
+ condition: data,
|
|
|
});
|
|
|
form.init();
|
|
|
},
|
|
|
methods: {
|
|
|
- initDemand(demand){
|
|
|
+ initDemand(demand) {
|
|
|
demand['status'] = this.status[demand['status']]['value'] ?? '';
|
|
|
- demand['type'] = this.types[demand['type']]['value'] ?? '';
|
|
|
+ demand['type'] = this.types[demand['type']]['value'] ?? '';
|
|
|
+ demand.showAddDiv= false;
|
|
|
+ if (demand['upload_file']) this.setImgUrl(demand['upload_file']);
|
|
|
+ if(demand['processes']){
|
|
|
+ demand['processes'].forEach(function(item,index,self){
|
|
|
+ self[index]['status'] = false;
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setImgUrl(uploadFile) {
|
|
|
+ let url = '{{url('/storage/')}}';
|
|
|
+ let urlPath = uploadFile['url'];
|
|
|
+ let type = uploadFile.type;
|
|
|
+ uploadFile['url'] = url + urlPath + '-thumbnail.' + type;
|
|
|
+ uploadFile['bulkyUrl'] = url + urlPath + '-bulky.' + type;
|
|
|
+ uploadFile['commonUrl'] = url + urlPath + '-thumbnail.' + type;
|
|
|
},
|
|
|
/** 完结需求 */
|
|
|
- finishDemand(demand){
|
|
|
+ finishDemand(demand) {
|
|
|
let url = '{{url('apiLocal/demand/finish')}}';
|
|
|
window.tempTip.setDuration(3000);
|
|
|
- window.axios.post(url,{id:demand['id']}).then(res=>{
|
|
|
- if(res.data.success){
|
|
|
+ window.axios.post(url, {id: demand['id']}).then(res => {
|
|
|
+ if (res.data.success) {
|
|
|
window.tempTip.showSuccess('需求完结成功');
|
|
|
demand.status = '已处理'
|
|
|
- return ;
|
|
|
+ return;
|
|
|
}
|
|
|
- window.tempTip.show('需求完结失败'+res.data.data);
|
|
|
- }).catch(err=>{
|
|
|
- window.tempTip.show('需求完结异常'+err);
|
|
|
+ window.tempTip.show('需求完结失败' + res.data.data);
|
|
|
+ }).catch(err => {
|
|
|
+ window.tempTip.show('需求完结异常' + err);
|
|
|
});
|
|
|
},
|
|
|
/** 删除 */
|
|
|
- destroyDemand(demand,index){
|
|
|
- if(!confirm('确定要删除当前需求吗?')){return ;}
|
|
|
+ destroyDemand(demand, index) {
|
|
|
+ if (!confirm('确定要删除当前需求吗?')) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- let url = '{{url('apiLocal/demand/destroy?id=')}}'+demand['id'];
|
|
|
+ let url = '{{url('apiLocal/demand/destroy?id=')}}' + demand['id'];
|
|
|
|
|
|
window.tempTip.setDuration(3000);
|
|
|
- window.axios.delete(url).then(res=>{
|
|
|
- if(res.data.success){
|
|
|
+ window.axios.delete(url).then(res => {
|
|
|
+ if (res.data.success) {
|
|
|
window.tempTip.showSuccess('删除成功!');
|
|
|
- this.$delete(this.demands,index);
|
|
|
- return ;
|
|
|
+ this.$delete(this.demands, index);
|
|
|
+ return;
|
|
|
}
|
|
|
window.tempTip.show(res.data.data);
|
|
|
- }).catch(err=>{
|
|
|
- window.tempTip.show('删除出现异常'+err);
|
|
|
+ }).catch(err => {
|
|
|
+ window.tempTip.show('删除出现异常' + err);
|
|
|
});
|
|
|
},
|
|
|
/** 添加处理过程 */
|
|
|
- addProcess(demand,$e){
|
|
|
+ addProcess(demand, $e) {
|
|
|
let url = '{{url('apiLocal/demand/process/store')}}';
|
|
|
- let data = {'demand_id':demand['id'],'explain':$($e.target).val()};
|
|
|
+ let data = {'demand_id': demand['id'], 'explain': $($e.target).val()};
|
|
|
|
|
|
window.tempTip.setDuration(3000);
|
|
|
- window.axios.post(url,data).then(res=>{
|
|
|
- if(res.data.success){
|
|
|
+ window.axios.post(url, data).then(res => {
|
|
|
+ if (res.data.success) {
|
|
|
demand['processes'].unshfit(res.data.data);
|
|
|
this.$forceUpdate();
|
|
|
|
|
|
window.tempTip.showSuccess('添加处理过程成功')
|
|
|
- return ;
|
|
|
+ return;
|
|
|
}
|
|
|
window.tempTip.show('添加处理过程失败')
|
|
|
- }).catch(err=>{
|
|
|
- window.tempTip.show('添加处理过程异常:'+err);
|
|
|
+ }).catch(err => {
|
|
|
+ window.tempTip.show('添加处理过程异常:' + err);
|
|
|
})
|
|
|
|
|
|
},
|
|
|
/** 文件上传 */
|
|
|
- uploadFile(){
|
|
|
+ uploadFile() {
|
|
|
let fileInput = document.querySelector('#upLoadFile-input');
|
|
|
let url = '{{url('apiLocal/demand/uploadFile')}}';
|
|
|
|
|
|
let formData = new FormData();
|
|
|
- formData.append('id',this.selectDemand);
|
|
|
+ formData.append('id', this.selectDemand);
|
|
|
let file = fileInput.files[0];
|
|
|
- formData.append('file',file);
|
|
|
+ formData.append('file', file);
|
|
|
|
|
|
window.tempTip.setDuration(3000);
|
|
|
- window.axios.post(url,formData).then(res=>{
|
|
|
- if(res.data.success){
|
|
|
+ window.tempTip.setIndex(1999);
|
|
|
+ window.axios.post(url, formData, {
|
|
|
+ 'Content-Type': 'multipart/form-data'
|
|
|
+ }).then(res => {
|
|
|
+ if (res.data.success) {
|
|
|
this.initDemand(res.data.data);
|
|
|
- this.$set(this.demands,this.selectIndex,res.data.data);
|
|
|
+ this.$set(this.demands, this.selectIndex, res.data.data);
|
|
|
$('#uploadFile').modal('hide');
|
|
|
window.tempTip.showSuccess('文件上传成功');
|
|
|
return;
|
|
|
}
|
|
|
window.tempTip.show('文件上传失败');
|
|
|
- }).catch(err=>{
|
|
|
- window.tempTip.show('文件上传异常:'+err);
|
|
|
+ }).catch(err => {
|
|
|
+ window.tempTip.show('文件上传异常:' + err);
|
|
|
});
|
|
|
},
|
|
|
/** 修改需求描述 */
|
|
|
- updateDemand(demand,column,$e){
|
|
|
+ updateDemand(demand, column, $e) {
|
|
|
let url = '{{url('apiLocal/demand/update')}}';
|
|
|
- let data = {'id':demand['id']};
|
|
|
+ let data = {'id': demand['id']};
|
|
|
let value = $($e.target).val();
|
|
|
data[column] = value;
|
|
|
|
|
|
window.tempTip.setDuration(3000);
|
|
|
- window.axios.post(url,data).then(res=>{
|
|
|
- if(res.data.success){
|
|
|
+ window.axios.post(url, data).then(res => {
|
|
|
+ if (res.data.success) {
|
|
|
demand[column] = value;
|
|
|
this.$forceUpdate();
|
|
|
window.tempTip.showSuccess('修改需求成功');
|
|
|
return;
|
|
|
}
|
|
|
window.tempTip.show(res.data.data);
|
|
|
- }).catch(err=>{
|
|
|
- window.tempTip.show('修改需求描述异常:'+err);
|
|
|
+ }).catch(err => {
|
|
|
+ window.tempTip.show('修改需求描述异常:' + err);
|
|
|
});
|
|
|
},
|
|
|
/** 问题认领 */
|
|
|
- claimDemand(demand,index){
|
|
|
+ claimDemand(demand, index) {
|
|
|
console.log(demand);
|
|
|
let url = '{{url('apiLocal/demand/claim')}}';
|
|
|
window.tempTip.setDuration(3000);
|
|
|
- window.axios.post(url,{id:demand['id']}).then(res=>{
|
|
|
- if(res.data.success){
|
|
|
+ window.axios.post(url, {id: demand['id']}).then(res => {
|
|
|
+ if (res.data.success) {
|
|
|
this.initDemand(res.data.data);
|
|
|
- this.$set(this.demands,index,res.data.data);
|
|
|
+ this.$set(this.demands, index, res.data.data);
|
|
|
window.tempTip.showSuccess('认领成功!');
|
|
|
- return ;
|
|
|
+ return;
|
|
|
}
|
|
|
- if(res.data.errors)window.tempTip.show(res.data.errors);
|
|
|
+ if (res.data.errors) window.tempTip.show(res.data.errors);
|
|
|
else window.tempTip.show(res.data.data);
|
|
|
- }).catch(err=>{
|
|
|
- window.tempTip.show('认领出现异常'+err);
|
|
|
+ }).catch(err => {
|
|
|
+ window.tempTip.show('认领出现异常' + err);
|
|
|
});
|
|
|
},
|
|
|
- showUploadDiv(demand,index){
|
|
|
+ showUploadDiv(demand, index) {
|
|
|
this.selectDemand = demand['id'];
|
|
|
this.selectIndex = index;
|
|
|
$('#uploadFile').modal('show');
|
|
|
+ },
|
|
|
+
|
|
|
+ lazy() {
|
|
|
+ //可视区域高度
|
|
|
+ let height = window.innerHeight;
|
|
|
+ //滚动区域高度
|
|
|
+ let scrollHeight = document.documentElement.scrollTop || document.body.scrollTop;
|
|
|
+ let _this = this;
|
|
|
+ this.imgs.forEach(function (img, i) {
|
|
|
+ if ((height + scrollHeight) > $('#' + img.getAttribute('id')).offset().top && img.getAttribute('data-src')) {
|
|
|
+ let temp = new Image();
|
|
|
+ temp.src = img.getAttribute('data-src');
|
|
|
+ temp.onload = function () {
|
|
|
+ img.src = img.getAttribute('data-src');
|
|
|
+ _this.$delete(_this.imgs, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ removeCommonImg(id) {
|
|
|
+ $('#' + id).remove();
|
|
|
+ },
|
|
|
+ commonImg(id, demand,index) {
|
|
|
+ if (!demand['upload_file']) return;
|
|
|
+ let bulkyUrl = demand['upload_file']['bulkyUrl'];
|
|
|
+ let commonUrl = demand['upload_file']['commonUrl'];
|
|
|
+ $('#' + id).after(
|
|
|
+ "<div id=\"imgBulky_" + demand['id'] + "\" style='position: absolute;padding-top: 2px;z-index: 99'>" +
|
|
|
+ "<div style='position:absolute'>" +
|
|
|
+ "<div >" +
|
|
|
+ "<a target='_blank' href='" + bulkyUrl + "'>" +
|
|
|
+ "<img src='" + commonUrl + "'" + "style='position: relative;left:-50px;' >" +
|
|
|
+ "</a>" +
|
|
|
+ "</div>" +
|
|
|
+ "<button type='button' class='btn btn-sm btn-danger' onclick='demand_vue.btnDeleteImg(this,"+index+")' value='" + id + "' style='position: relative;float: right;margin-right: 51px;margin-top: -30px;' >删除</button>" +
|
|
|
+ "</div>" +
|
|
|
+ "</div>");
|
|
|
+ },
|
|
|
+ btnDeleteImg(e,index) {
|
|
|
+ let idStr = $(e).val()
|
|
|
+ let id = idStr.substr(idStr.indexOf('_') + 1)
|
|
|
+ if (!confirm('确定要删除所选图片吗?')) return;
|
|
|
+ this.destroyImg(id,index);
|
|
|
+ },
|
|
|
+ destroyImg(id,index) {
|
|
|
+ let url = '{{url('apiLocal/demand/destroyFile/?id=')}}'+id;
|
|
|
+ window.tempTip.setDuration(3000);
|
|
|
+ window.axios.delete(url).then(res=>{
|
|
|
+ if(res.data.success){
|
|
|
+ window.tempTip.showSuccess('附件删除成功!');
|
|
|
+ this.$delete(this.demands[index],['upload_file']);
|
|
|
+ this.$forceUpdate();
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ window.tempTip.show('附件删除异常:'+res.data.data);
|
|
|
+ }).catch(err=>{
|
|
|
+ window.tempTip.show(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ toggleAddDiv(id){
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
});
|