|
|
@@ -6,12 +6,14 @@
|
|
|
@component('customer.menu')@endcomponent
|
|
|
@component('customer.customer.menu')@endcomponent
|
|
|
</div>
|
|
|
- <div class="container-fluid card" id="container">
|
|
|
+ <div class="d-none container-fluid card" id="container">
|
|
|
<div class="card-body mt-2">
|
|
|
+ <div id="form_div" class="mb-2"></div>
|
|
|
@if(Session::has('successTip'))
|
|
|
<div class="alert alert-success h1">{{Session::get('successTip')}}</div>
|
|
|
@endif
|
|
|
@include("customer.customer._customerLog")
|
|
|
+ @include("customer.customer._addContract")
|
|
|
<table class="table table-striped table-hover text-nowrap">
|
|
|
<tr>
|
|
|
<th>序号</th>
|
|
|
@@ -27,7 +29,7 @@
|
|
|
<th>创建时间</th>
|
|
|
<th>操作</th>
|
|
|
</tr>
|
|
|
- <tr v-for="(customer,i) in customers">
|
|
|
+ <tr v-for="(customer,i) in customers" :id="'model-'+customer.id">
|
|
|
<td>@{{ i+1 }}</td>
|
|
|
<td>@{{ customer.code }}</td>
|
|
|
<td>@{{ customer.name }}</td>
|
|
|
@@ -36,11 +38,15 @@
|
|
|
<td>@{{ customer.contact_man }}</td>
|
|
|
<td>@{{ customer.phone }}</td>
|
|
|
<td>@{{ customer.remark }}</td>
|
|
|
- <td><span class="cursor-pointer" data-toggle="modal" data-target="#modal">查看</span></td>
|
|
|
- <td>#</td>
|
|
|
+ <td><span class="cursor-pointer" @click="showCustomerLog(customer.id,i)">查看</span></td>
|
|
|
+ <td v-if="customer.contractQuantity>0" class="cursor-pointer" @click="showContract(customer.id)"><span class="fa" :class="contractIds['_'+customer.id] === true ? 'fa-angle-double-down' : 'fa-angle-double-right'"></span>@{{ customer.contractQuantity }}份合同</td>
|
|
|
+ <td v-else>#</td>
|
|
|
<td>@{{ customer.created_at }}</td>
|
|
|
<td>
|
|
|
- @can("客户-编辑")<a :href="'{{url('customer/customer')}}/'+customer.id+'/edit'"><button class="btn btn-sm btn-outline-info">改</button></a>@endcan
|
|
|
+ @can("客户-编辑")
|
|
|
+ <button class="btn btn-sm btn-outline-success" @click="addContract(i)">新建合同</button>
|
|
|
+ <a :href="'{{url('customer/customer')}}/'+customer.id+'/edit'"><button class="btn btn-sm btn-outline-info">改</button></a>
|
|
|
+ @endcan
|
|
|
@can("客户-删除")<button class="btn btn-sm btn-outline-danger" @click="destroy(customer.id,i,customer.name)">删</button>@endcan
|
|
|
</td>
|
|
|
</tr>
|
|
|
@@ -50,13 +56,68 @@
|
|
|
@stop
|
|
|
|
|
|
@section('lastScript')
|
|
|
+ <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
|
|
|
<script>
|
|
|
new Vue({
|
|
|
el:"#container",
|
|
|
data:{
|
|
|
- customers : {!! $customers->toJson() !!}['data']
|
|
|
+ customers : {!! $customers->toJson() !!}['data'],
|
|
|
+ customerLogs : [],
|
|
|
+ index:'',
|
|
|
+ currentLogIndex:"",
|
|
|
+ logStatuses:[],
|
|
|
+ contractIds:[],
|
|
|
+ owners:[],
|
|
|
+ files:[],
|
|
|
+ },
|
|
|
+ mounted(){
|
|
|
+ $('#container').removeClass('d-none');
|
|
|
+ this.rendering();
|
|
|
+ let data=[
|
|
|
+ [
|
|
|
+ {name:'company_name',type:'input',tip:'可在检索值前加百分号(%)进行模糊搜索',placeholder:'公司名称'},
|
|
|
+ {name:'contact_man',type:'input',tip:'可在检索值前加百分号(%)进行模糊搜索',placeholder:'联系人'},
|
|
|
+ {name:'phone',type:'input',tip:'可在检索值前加百分号(%)进行模糊搜索',placeholder:'联系电话'},
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ new query({
|
|
|
+ el:"#form_div",
|
|
|
+ condition:data,
|
|
|
+ }).init();
|
|
|
},
|
|
|
methods:{
|
|
|
+ selectFile(){
|
|
|
+ $("#files").click();
|
|
|
+ },
|
|
|
+ uploadFiles(event){
|
|
|
+ let files = event.target.files;
|
|
|
+ for(let i=0;i<files.length;i++){
|
|
|
+ this.files.push(files[i]);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deleteFile(index){
|
|
|
+ this.$delete(this.files,index);
|
|
|
+ },
|
|
|
+ rendering() {
|
|
|
+ this.customers.forEach((customer,i)=> {
|
|
|
+ let contracts = [];
|
|
|
+ if (customer.owners)
|
|
|
+ customer.owners.forEach(owner=> {
|
|
|
+ if (owner.contracts)
|
|
|
+ owner.contracts.forEach(contract=>{
|
|
|
+ contracts.push({
|
|
|
+ number:contract.contract_number,
|
|
|
+ salesman:contract.salesman,
|
|
|
+ remark:contract.remark,
|
|
|
+ ownerName:owner.name,
|
|
|
+ files:contract.files ? contract.files : []});
|
|
|
+ });
|
|
|
+ });
|
|
|
+ customer["contractQuantity"] = contracts.length;
|
|
|
+ this._renderingHtml(customer.id,contracts);
|
|
|
+ });
|
|
|
+ this.$forceUpdate();
|
|
|
+ },
|
|
|
destroy(id,index,name){
|
|
|
window.tempTip.confirm("确定要删除"+name+"吗?",()=>{
|
|
|
window.axios.delete("{{url('customer/customer')}}/"+id)
|
|
|
@@ -75,6 +136,185 @@
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ showCustomerLog(id,index){
|
|
|
+ this.index = index;
|
|
|
+ if (this.customerLogs[id]){
|
|
|
+ $("#modal").modal('show');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let url="{{url('customer/customer/getLog')}}";
|
|
|
+ let params = {customer_id:id};
|
|
|
+ window.tempTip.postBasicRequest(url,params,(res)=> {
|
|
|
+ this.customerLogs[id] = res;
|
|
|
+ this.$forceUpdate();
|
|
|
+ $("#modal").modal('show');
|
|
|
+ });
|
|
|
+ },
|
|
|
+ textClass(event,isOver){
|
|
|
+ event = event.target.children[0];
|
|
|
+ if (isOver){event.classList.remove("text-overflow-replace");}
|
|
|
+ else {event.classList.add("text-overflow-replace");}
|
|
|
+ },
|
|
|
+ edit(index,user){
|
|
|
+ let id = "{{\Illuminate\Support\Facades\Auth::id()}}";
|
|
|
+ if (id != user.id) return;
|
|
|
+ if (index === 0)this.currentLogIndex=index;
|
|
|
+ else this.currentLogIndex='';
|
|
|
+ },
|
|
|
+ closeEditLog(){
|
|
|
+ this.currentLogIndex = '';
|
|
|
+ if (this.customerLogs[this.customers[this.index]['id']][0].id === ''){
|
|
|
+ this.$delete(this.customerLogs[this.customers[this.index]['id']],0);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ editLog(){
|
|
|
+ let log = this.customerLogs[this.customers[this.index]['id']][this.currentLogIndex];
|
|
|
+ if (log.id === ''){
|
|
|
+ let description = $("#description-"+log.id)[0].value;
|
|
|
+ let logStatus = $("#logStatus-"+log.id)[0].value;
|
|
|
+ let url="{{url('customer/customer/storeLog')}}";
|
|
|
+ let params = {customer_id:this.customers[this.index]['id'],description:description,customer_log_status_id:logStatus};
|
|
|
+ window.tempTip.postBasicRequest(url,params,(res)=>{
|
|
|
+ this.customerLogs[this.customers[this.index]['id']][0] = res;
|
|
|
+ this.currentLogIndex = '';
|
|
|
+ this.$forceUpdate();
|
|
|
+ return "成功创建客户日志";
|
|
|
+ },true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let url="{{url('customer/customer/editLog')}}";
|
|
|
+ let description = $("#description-"+log.id)[0].value;
|
|
|
+ let params = {id:log.id,description:description};
|
|
|
+ window.tempTip.postBasicRequest(url,params,(res)=> {
|
|
|
+ this.customerLogs[this.customers[this.index]['id']][this.currentLogIndex].description = description;
|
|
|
+ this.currentLogIndex = '';
|
|
|
+ this.$forceUpdate();
|
|
|
+ return "修改说明成功!";
|
|
|
+ },true);
|
|
|
+ },
|
|
|
+ addLog(){
|
|
|
+ if (this.logStatuses.length < 1)window.tempTip.postBasicRequest("{{url('customer/customer/getLogStatus')}}",{},(res)=>{
|
|
|
+ this.logStatuses = res;
|
|
|
+ },true);
|
|
|
+ let logs = this.customerLogs[this.customers[this.index]['id']];
|
|
|
+ if (logs.length > 0 && logs[0].id === "")return;
|
|
|
+ logs.unshift({
|
|
|
+ id:"",
|
|
|
+ status:{name:""},
|
|
|
+ user:{name:"{{\Illuminate\Support\Facades\Auth::user()->name}}"},
|
|
|
+ description:"",
|
|
|
+ created_at:"",
|
|
|
+ });
|
|
|
+ this.currentLogIndex = 0;
|
|
|
+ this.$forceUpdate();
|
|
|
+ },
|
|
|
+ showContract(id){
|
|
|
+ if (this.contractIds['_'+id] && this.contractIds['_'+id]===true){
|
|
|
+ this.contractIds['_'+id] = false;
|
|
|
+ $("#customer-"+id).slideUp(undefined,function () {
|
|
|
+ $("#customer-tr-"+id).addClass("d-none");
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ $("#customer-tr-"+id).removeClass("d-none");
|
|
|
+ this.contractIds['_'+id] = true;
|
|
|
+ $("#customer-"+id).slideDown();
|
|
|
+ }
|
|
|
+ this.$forceUpdate();
|
|
|
+ },
|
|
|
+ _renderingHtml(id,contracts){
|
|
|
+ let domId = "customer-"+id;
|
|
|
+ let trDomId = "customer-tr-"+id;
|
|
|
+ let html = "<tr class='d-none' id='"+trDomId+"'><td colspan='12'>"+
|
|
|
+ "<div id='"+domId+"'><table class='table table-sm'>"+
|
|
|
+ "<tr><th>合同号</th><th>销售姓名</th><th>所属项目</th><th>备注</th><th>附件</th></tr>";
|
|
|
+ contracts.forEach(contract=> {
|
|
|
+ html = this._createContractList(html,contract.number,contract.salesman,contract.ownerName,contract.remark,contract.files);
|
|
|
+ });
|
|
|
+ html += "</table></div></td></tr>";
|
|
|
+ $("#model-"+id).after(html);
|
|
|
+ $("#"+domId).slideUp();
|
|
|
+ },
|
|
|
+ _createContractList(html,number,salesman,ownerName,remark,files){
|
|
|
+ html += "<tr><td>"+number+"</td><td>"+salesman+"</td><td>"+ownerName+"</td><td><div style='white-space: normal;max-width: 200px' '>"+remark+"</div</td><td class='p-0'>";
|
|
|
+ if (files) files.forEach(function (file) {
|
|
|
+ let url = file.url;
|
|
|
+ let name = file.file_name;
|
|
|
+ if (file.type === 'jpg' || file.type === 'png'){
|
|
|
+ html += "<a target='_blank' href='"+url+"' class='small'><span class='fa fa-file-image-o'></span>"+name+"</a><br>";
|
|
|
+ }else html += "<a target='_blank' href='"+url+"' download='"+url+"' class='small'><span class='fa fa-link'></span>"+name+"</a><br>";
|
|
|
+ });
|
|
|
+ html += "</td></tr>";
|
|
|
+ return html;
|
|
|
+ },
|
|
|
+ addContract(index){
|
|
|
+ this.index = index;
|
|
|
+ let id = this.customers[index].id;
|
|
|
+ if (!this.owners[id]){
|
|
|
+ let url = "{{url("maintenance/owner/get")}}";
|
|
|
+ let params = {customer_id:id};
|
|
|
+ window.tempTip.postBasicRequest(url,params,(res)=> {
|
|
|
+ this.owners[id] = res;
|
|
|
+ this.$forceUpdate();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ $("#addContract").modal("show");
|
|
|
+ },
|
|
|
+ submitContract(){
|
|
|
+ window.tempTip.setIndex(1099);
|
|
|
+ let owner = document.getElementById("owner").value;
|
|
|
+ let number = document.getElementById("contract_number").value;
|
|
|
+ let remark = document.getElementById("remark").value;
|
|
|
+ if (!owner || !number){
|
|
|
+ window.tempTip.show("项目与合同号为必输项");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let formData = new FormData();
|
|
|
+ this.files.forEach(file=>{
|
|
|
+ formData.append("files[]",file);
|
|
|
+ });
|
|
|
+ formData.append("owner_id",owner);
|
|
|
+ formData.append("contract_number",number);
|
|
|
+ formData.append("remark",remark);
|
|
|
+ window.tempTip.setDuration(9999);
|
|
|
+ window.tempTip.waitingTip("新建中,请耐心等候......");
|
|
|
+ window.axios.post('{{url('customer/ownerContract/store')}}',formData,{
|
|
|
+ 'Content-Type':'multipart/form-data'
|
|
|
+ }).then(res=>{
|
|
|
+ if (res.data.success){
|
|
|
+ window.tempTip.cancelWaitingTip();
|
|
|
+ window.tempTip.setDuration(2000);
|
|
|
+ window.tempTip.showSuccess("新建合同“"+number+"”成功");
|
|
|
+ $("#addContract").modal("hide");
|
|
|
+ this.files = [];
|
|
|
+ let id = this.customers[this.index].id;
|
|
|
+ let html = this._createContractList('',
|
|
|
+ res.data.data.contract_number,
|
|
|
+ res.data.data.salesman,
|
|
|
+ res.data.data.owner ? res.data.data.owner.name : '',
|
|
|
+ res.data.data.remark,
|
|
|
+ res.data.data.files);
|
|
|
+ $("#customer-tr-"+id).after(html);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ window.tempTip.cancelWaitingTip();
|
|
|
+ window.tempTip.setDuration(3000);
|
|
|
+ window.tempTip.show(res.data.data);
|
|
|
+ }).catch(err=>{
|
|
|
+ window.tempTip.cancelWaitingTip();
|
|
|
+ window.tempTip.setDuration(3000);
|
|
|
+ window.tempTip.show('网络错误:'+err);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ filters:{
|
|
|
+ size:function (val) {
|
|
|
+ if (!val)return '';
|
|
|
+ val = Number(parseInt(val/1024));
|
|
|
+ if (val >= 1024){
|
|
|
+ return parseInt(val/1024)+"MB";
|
|
|
+ }
|
|
|
+ return val+"KB";
|
|
|
+ }
|
|
|
},
|
|
|
});
|
|
|
</script>
|