|
|
@@ -65,10 +65,13 @@
|
|
|
@can('采购管理-采购-新建')
|
|
|
@include('procurement.procurement._addEnquiry')
|
|
|
@endcan
|
|
|
- <span class="btn btn-sm btn-outline-danger ml-2" @click="addProof">新增打样</span>
|
|
|
+ <span class="btn btn-sm btn-outline-danger ml-2" @click="addProof">新增打样</span>
|
|
|
@can('采购管理-采购-新建')
|
|
|
@include('procurement.procurement._addProof')
|
|
|
@endcan
|
|
|
+ @can('采购管理-采购-编辑')
|
|
|
+ @include('procurement.procurement._addQuantity')
|
|
|
+ @endcan
|
|
|
<span class="btn btn-sm btn-outline-primary ml-2">重新发起</span>
|
|
|
</div>
|
|
|
<label for="all" id="cloneCheckAll" class="d-none">
|
|
|
@@ -84,23 +87,37 @@
|
|
|
</td>
|
|
|
<td class="">@{{ procurement.code }}</td>
|
|
|
<td v-if="procurement.owner_material.owner">@{{ procurement.owner_material.owner.name }}</td>
|
|
|
- <td >@{{ procurement_type[procurement.type] }}</td>
|
|
|
- <td v-if="procurement.owner_material.owner.customer">@{{ procurement.owner_material.owner.customer.company_name }}</td>
|
|
|
- <td class="tooltipTarget" style="max-width: 200px;overflow:hidden" v-if="procurement.owner_material.material">@{{ procurement.owner_material.material.code }}</td>
|
|
|
- <td class="text-muted" v-if="procurement.owner_material.material">@{{ procurement.owner_material.material.name }}</td>
|
|
|
+ <td>@{{ procurement_type[procurement.type] }}</td>
|
|
|
+ <td v-if="procurement.owner_material.owner.customer">@{{
|
|
|
+ procurement.owner_material.owner.customer.company_name }}
|
|
|
+ </td>
|
|
|
+ <td class="tooltipTarget" style="max-width: 200px;overflow:hidden"
|
|
|
+ v-if="procurement.owner_material.material">@{{ procurement.owner_material.material.code }}
|
|
|
+ </td>
|
|
|
+ <td class="text-muted" v-if="procurement.owner_material.material">@{{
|
|
|
+ procurement.owner_material.material.name }}
|
|
|
+ </td>
|
|
|
<td class="text-muted" v-if="procurement.owner_material">@{{ procurement.owner_material.size }}</td>
|
|
|
<td class="text-muted" v-if="procurement.owner_material">@{{ procurement.owner_material.special }}</td>
|
|
|
- <td class="text-muted" v-if="procurement.owner_material">@{{ procurement.owner_material.specification }}</td>
|
|
|
+ <td class="text-muted" v-if="procurement.owner_material">@{{ procurement.owner_material.specification
|
|
|
+ }}
|
|
|
+ </td>
|
|
|
<td></td>
|
|
|
<td>@{{ procurement.quantity }}</td>
|
|
|
<td><span>@{{ procurement.unit_price }}</span></td>
|
|
|
<td><span></span></td>
|
|
|
- <td><span></span></td>
|
|
|
+ <td>@{{ procurement.quantity*procurement.unit_price }}</td>
|
|
|
<td><span>@{{ procurement_status[procurement.status] }}</span></td>
|
|
|
- <td v-if="procurement.owner_material.owner.customer">@{{ procurement.owner_material.owner.customer.phone }}</td>
|
|
|
+ <td v-if="procurement.owner_material.owner.customer">@{{ procurement.owner_material.owner.customer.phone
|
|
|
+ }}
|
|
|
+ </td>
|
|
|
<td>
|
|
|
- <span class="btn btn-sm btn-outline-danger" v-if="procurement.supplier_id">取消</span>
|
|
|
- <span class="btn btn-sm btn-outline-success" v-if="procurement.type==1">发起采购</span>
|
|
|
+ <span v-if="procurement_status[procurement.status]!='取消订单'">
|
|
|
+ <span class="btn btn-sm btn-outline-danger" v-if="!procurement.supplier_id"
|
|
|
+ @click="cancel(procurement.id,procurement.type,procurement.code)">取消</span>
|
|
|
+ <span class="btn btn-sm btn-outline-success" v-if="procurement_type[procurement.type]=='询价单'"
|
|
|
+ @click="initiateProcurement(procurement.id)">发起采购</span>
|
|
|
+ </span>
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
@@ -118,43 +135,52 @@
|
|
|
data: {
|
|
|
countReceive:{!! $countReceive !!},
|
|
|
countProcurement:{!! $countProcurement !!},
|
|
|
- procurements:{!! $procurements->toJson() !!}['data'],
|
|
|
- owners:[
|
|
|
+ procurements: {!! $procurements->toJson() !!}['data'],
|
|
|
+ owners: [
|
|
|
@foreach($owners as $owner)
|
|
|
{
|
|
|
- name:'{{$owner->id}}',value:'{{$owner->name}}',
|
|
|
- ownerMaterials:[
|
|
|
+ name: '{{$owner->id}}', value: '{{$owner->name}}',
|
|
|
+ ownerMaterials: [
|
|
|
@foreach($owner->ownerMaterials ? $owner->ownerMaterials :[] as $ownerMaterial)
|
|
|
{
|
|
|
- id:'{{$ownerMaterial->id}}',material_code:'{{$ownerMaterial->material_code}}',material_name:'{{$ownerMaterial->material->name}}',
|
|
|
- size:'{{$ownerMaterial->size}}',special:'{{$ownerMaterial->special}}',specification:'{{$ownerMaterial->specification}}',
|
|
|
+ id: '{{$ownerMaterial->id}}',
|
|
|
+ material_code: '{{$ownerMaterial->material_code}}',
|
|
|
+ material_name: '{{$ownerMaterial->material->name}}',
|
|
|
+ size: '{{$ownerMaterial->size}}',
|
|
|
+ special: '{{$ownerMaterial->special}}',
|
|
|
+ specification: '{{$ownerMaterial->specification}}',
|
|
|
},
|
|
|
@endforeach
|
|
|
],
|
|
|
+ @if($owner->customer)customer_name: '{{$owner->customer->name}}',@endif
|
|
|
},
|
|
|
@endforeach
|
|
|
],
|
|
|
materials: [
|
|
|
@foreach($materials as $material)
|
|
|
- {name:'{{$material->id}}',value:'{{$material->name}}'},
|
|
|
+ {
|
|
|
+ name: '{{$material->id}}', value: '{{$material->name}}'
|
|
|
+ },
|
|
|
@endforeach
|
|
|
],
|
|
|
procurement_type:{!! json_encode(\App\Procurement::type,JSON_UNESCAPED_UNICODE) !!},
|
|
|
procurement_status:{!! json_encode(\App\Procurement::status,JSON_UNESCAPED_UNICODE) !!},
|
|
|
checkData: [],
|
|
|
sum:{!! $procurements->total() !!},
|
|
|
- owner_id:'{{old('owner_id')}}',
|
|
|
- owner_material_id:'{{old('owner_material_id')}}',
|
|
|
- material_name:'{{old('material_name')}}',
|
|
|
- size:'{{old('size')}}',
|
|
|
- special:'{{old('special')}}',
|
|
|
- specification:'{{old('specification')}}',
|
|
|
- quantity:'{{old('quantity')}}',
|
|
|
- amount:'{{old('amount')}}',
|
|
|
- unit_price:'{{old('unit_price')}}',
|
|
|
- total_price:'{{old('total_price')}}',
|
|
|
- ownerMaterials:[],
|
|
|
- errors:{},
|
|
|
+ owner_id: '{{old('owner_id')}}',
|
|
|
+ owner_material_id: '{{old('owner_material_id')}}',
|
|
|
+ material_name: '{{old('material_name')}}',
|
|
|
+ customer_name: '{{old('customer_name')}}',
|
|
|
+ size: '{{old('size')}}',
|
|
|
+ special: '{{old('special')}}',
|
|
|
+ specification: '{{old('specification')}}',
|
|
|
+ quantity: '{{old('quantity')}}',
|
|
|
+ amount: '{{old('amount')}}',
|
|
|
+ unit_price: '{{old('unit_price')}}',
|
|
|
+ total_price: '{{old('total_price')}}',
|
|
|
+ procurement_id:'',supplier:'',offer:'',supplier_id:'',
|
|
|
+ ownerMaterials: [],
|
|
|
+ errors: {},
|
|
|
|
|
|
},
|
|
|
mounted: function () {
|
|
|
@@ -169,8 +195,11 @@
|
|
|
placeholder: ['项目', '定位或多选项目'], data: this.owners
|
|
|
},
|
|
|
{
|
|
|
- name: 'material_id', type: 'select_multiple_select', tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的耗材'],
|
|
|
- placeholder: ['耗材', '定位或多选耗材'], data: this.materials
|
|
|
+ name: 'material_id',
|
|
|
+ type: 'select_multiple_select',
|
|
|
+ tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的耗材'],
|
|
|
+ placeholder: ['耗材', '定位或多选耗材'],
|
|
|
+ data: this.materials
|
|
|
},
|
|
|
{name: 'company_name', type: 'input', tip: '采购公司:可在两侧增加百分号(%)进行模糊搜索', placeholder: '采购公司'},
|
|
|
],
|
|
|
@@ -182,7 +211,7 @@
|
|
|
this.form.init();
|
|
|
let column = [
|
|
|
{
|
|
|
- name: 'cloneCheckAll', customization: true, type: 'checkAll',column:'id',
|
|
|
+ name: 'cloneCheckAll', customization: true, type: 'checkAll', column: 'id',
|
|
|
dom: $('#cloneCheckAll').removeClass('d-none'), neglect: true
|
|
|
},
|
|
|
{name: 'code', value: '采购编号', neglect: true},
|
|
|
@@ -231,114 +260,208 @@
|
|
|
this.checkData = [];
|
|
|
}
|
|
|
},
|
|
|
- addProcurement(){
|
|
|
+ addProcurement() {
|
|
|
+ this.errors = {};
|
|
|
$('#add-procurement').modal('show');
|
|
|
},
|
|
|
- addEnquiry(){
|
|
|
+ addEnquiry() {
|
|
|
+ this.errors = {};
|
|
|
$('#add-enquiry').modal('show');
|
|
|
},
|
|
|
- addProof(){
|
|
|
+ addProof() {
|
|
|
+ this.errors = {};
|
|
|
$('#add-proof').modal('show');
|
|
|
},
|
|
|
- owner_seek:function (e) {
|
|
|
+ initiateProcurement(id) {
|
|
|
let _this=this;
|
|
|
- let $val=e.target.value;
|
|
|
- if($val===''){
|
|
|
- _this.owner_id='';
|
|
|
- }else{
|
|
|
+ this.procurement_id=id;
|
|
|
+ let url="{{url('procurement/procurement/initiateProcurement')}}";
|
|
|
+ let params={id:id};
|
|
|
+ window.axios.post(url,params).then(res => {
|
|
|
+ if (res.data.success) {
|
|
|
+ _this.supplier=res.data.data.supplier.name;
|
|
|
+ _this.supplier_id=res.data.data.supplier_id;
|
|
|
+ _this.offer=res.data.data.offer;
|
|
|
+ $('#add-quantity').modal('show');
|
|
|
+ } else {
|
|
|
+ tempTip.setDuration(3000);
|
|
|
+ tempTip.show(res.data.message);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ window.tempTip.setDuration(3000);
|
|
|
+ window.tempTip.show("网络错误:" + err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ owner_seek: function (e) {
|
|
|
+ let _this = this;
|
|
|
+ let $val = e.target.value;
|
|
|
+ if ($val === '') {
|
|
|
+ _this.owner_id = '';
|
|
|
+ } else {
|
|
|
_this.owners.forEach(function (owner) {
|
|
|
- if (owner.value.includes($val)){
|
|
|
- _this.owner_id=owner.name;
|
|
|
- _this.ownerMaterials=owner.ownerMaterials;
|
|
|
+ if (owner.value.includes($val)) {
|
|
|
+ _this.owner_id = owner.name;
|
|
|
+ _this.ownerMaterials = owner.ownerMaterials;
|
|
|
+ _this.customer_name = owner.customer_name;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- ownerMaterial:function () {
|
|
|
- let _this=this;
|
|
|
+ ownerMaterial: function () {
|
|
|
+ let _this = this;
|
|
|
_this.ownerMaterials.forEach(function (ownerMaterial) {
|
|
|
- if (_this.owner_material_id===ownerMaterial.id){
|
|
|
- _this.material_name=ownerMaterial.material_name;
|
|
|
- _this.size=ownerMaterial.size;
|
|
|
- _this.special=ownerMaterial.special;
|
|
|
- _this.specification=ownerMaterial.specification;
|
|
|
+ if (_this.owner_material_id === ownerMaterial.id) {
|
|
|
+ _this.material_name = ownerMaterial.material_name;
|
|
|
+ _this.size = ownerMaterial.size;
|
|
|
+ _this.special = ownerMaterial.special;
|
|
|
+ _this.specification = ownerMaterial.specification;
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- selectOwner:function () {
|
|
|
- let _this=this;
|
|
|
+ selectOwner: function () {
|
|
|
+ let _this = this;
|
|
|
_this.owners.forEach(function (owner) {
|
|
|
- if (_this.owner_id===owner.name){
|
|
|
- _this.ownerMaterials=owner.ownerMaterials;
|
|
|
+ if (_this.owner_id === owner.name) {
|
|
|
+ _this.ownerMaterials = owner.ownerMaterials;
|
|
|
+ _this.customer_name = owner.customer_name;
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- countTotalPrice:function () {
|
|
|
- let _this=this;
|
|
|
- if (_this.unit_price===''|| _this.amount==='')_this.total_price=null;
|
|
|
- _this.total_price=_this.unit_price*_this.amount;
|
|
|
+ countTotalPrice: function () {
|
|
|
+ let _this = this;
|
|
|
+ if (_this.unit_price === '' || _this.amount === '') _this.total_price = null;
|
|
|
+ _this.total_price = _this.unit_price * _this.amount;
|
|
|
},
|
|
|
- createProcurement(){
|
|
|
- let _this=this;
|
|
|
+ createProcurement() {
|
|
|
+ let _this = this;
|
|
|
let url = '{{url('procurement/procurement/createProcurement')}}';
|
|
|
- let params = {owner_material_id:_this.owner_material_id,quantity:_this.quantity,amount:_this.amount,unit_price:_this.unit_price};
|
|
|
- window.axios.post(url,params).then(function (res) {
|
|
|
- if (!res.data.success){
|
|
|
- _this.errors=res.data.errors;
|
|
|
- }else {
|
|
|
+ let params = {
|
|
|
+ owner_id: _this.owner_id,
|
|
|
+ owner_material_id: _this.owner_material_id,
|
|
|
+ quantity: _this.quantity,
|
|
|
+ amount: _this.amount,
|
|
|
+ unit_price: _this.unit_price
|
|
|
+ };
|
|
|
+ window.axios.post(url, params).then(function (res) {
|
|
|
+ if (!res.data.success) {
|
|
|
+ _this.errors = res.data.errors;
|
|
|
+ } else {
|
|
|
_this.procurements.push(res.data.data);
|
|
|
$("#add-procurement").modal('hide');
|
|
|
+ _this.clearData();
|
|
|
tempTip.setDuration(3000);
|
|
|
tempTip.showSuccess('新增采购单成功!');
|
|
|
|
|
|
}
|
|
|
}).catch(function (err) {
|
|
|
tempTip.setDuration(3000);
|
|
|
- tempTip.show('新增采购单失败!网络错误:'+err);
|
|
|
+ tempTip.show('新增采购单失败!网络错误:' + err);
|
|
|
});
|
|
|
},
|
|
|
- createEnquiry(){
|
|
|
- let _this=this;
|
|
|
+ createEnquiry() {
|
|
|
+ let _this = this;
|
|
|
let url = '{{url('procurement/procurement/createEnquiry')}}';
|
|
|
- let params = {owner_id:_this.owner_id,owner_material_id:_this.owner_material_id};
|
|
|
- window.axios.post(url,params).then(function (res) {
|
|
|
- if (!res.data.success){
|
|
|
- _this.errors=res.data.errors;
|
|
|
- }else {
|
|
|
+ let params = {owner_id: _this.owner_id, owner_material_id: _this.owner_material_id};
|
|
|
+ window.axios.post(url, params).then(function (res) {
|
|
|
+ if (!res.data.success) {
|
|
|
+ _this.errors = res.data.errors;
|
|
|
+ } else {
|
|
|
_this.procurements.push(res.data.data);
|
|
|
$("#add-enquiry").modal('hide');
|
|
|
+ _this.clearData();
|
|
|
tempTip.setDuration(3000);
|
|
|
tempTip.showSuccess('新增询价单成功!');
|
|
|
|
|
|
}
|
|
|
}).catch(function (err) {
|
|
|
tempTip.setDuration(3000);
|
|
|
- tempTip.show('新增询价单失败!网络错误:'+err);
|
|
|
+ tempTip.show('新增询价单失败!网络错误:' + err);
|
|
|
});
|
|
|
},
|
|
|
- createProof(){
|
|
|
- let _this=this;
|
|
|
+ createProof() {
|
|
|
+ let _this = this;
|
|
|
let url = '{{url('procurement/procurement/createProof')}}';
|
|
|
- let params = {owner_id:_this.owner_id,owner_material_id:_this.owner_material_id};
|
|
|
- window.axios.post(url,params).then(function (res) {
|
|
|
- if (!res.data.success){
|
|
|
- _this.errors=res.data.errors;
|
|
|
- }else {
|
|
|
+ let params = {owner_id: _this.owner_id, owner_material_id: _this.owner_material_id};
|
|
|
+ window.axios.post(url, params).then(function (res) {
|
|
|
+ if (!res.data.success) {
|
|
|
+ _this.errors = res.data.errors;
|
|
|
+ } else {
|
|
|
_this.procurements.push(res.data.data);
|
|
|
$("#add-proof").modal('hide');
|
|
|
+ _this.clearData();
|
|
|
tempTip.setDuration(3000);
|
|
|
tempTip.showSuccess('新增打样单成功!');
|
|
|
|
|
|
}
|
|
|
}).catch(function (err) {
|
|
|
tempTip.setDuration(3000);
|
|
|
- tempTip.show('新增打样单失败!网络错误:'+err);
|
|
|
+ tempTip.show('新增打样单失败!网络错误:' + err);
|
|
|
});
|
|
|
},
|
|
|
- procurementExport(selectAll){
|
|
|
+ clearData() {
|
|
|
+ this.owner_id = '';this.owner_material_id = '';
|
|
|
+ this.material_name = '';this.customer_name = '';
|
|
|
+ this.size = '';this.special = '';
|
|
|
+ this.specification = '';this.quantity = '';
|
|
|
+ this.amount = '';this.unit_price = '';
|
|
|
+ this.total_price = '';this.procurement_id='';
|
|
|
+ this.supplier_id='',this.offer='';
|
|
|
+ },
|
|
|
+ procurementExport(selectAll) {
|
|
|
let url = '{{url('procurement/procurement/procurementExport')}}';
|
|
|
- let token='{{ csrf_token() }}';
|
|
|
- excelExport(selectAll,this.checkData,url,this.sum,token);
|
|
|
+ let token = '{{ csrf_token() }}';
|
|
|
+ excelExport(selectAll, this.checkData, url, this.sum, token);
|
|
|
+ },
|
|
|
+ cancel(id, type, code) {
|
|
|
+ window.tempTip.confirm('确定取消' + this.procurement_type[type] + ' ' + code, () => {
|
|
|
+ window.axios.get("{{url('procurement/procurement/cancel')}}/" + id)
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.success) {
|
|
|
+ this.procurements.forEach(function (procurement) {
|
|
|
+ if (procurement.id === res.data.data.id) {
|
|
|
+ procurement.status = res.data.data.status;
|
|
|
+ window.tempTip.setDuration(2000);
|
|
|
+ window.tempTip.showSuccess("已成功取消该条采购申请");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ tempTip.setDuration(3000);
|
|
|
+ tempTip.show(res.data.message);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ window.tempTip.setDuration(3000);
|
|
|
+ window.tempTip.show("网络错误:" + err);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ submitProcurement() {
|
|
|
+ let _this=this;
|
|
|
+ let id=this.procurement_id;
|
|
|
+ if (!id)return;
|
|
|
+ let url="{{url('procurement/procurement/submitProcurement')}}";
|
|
|
+ let params={id:id,quantity:this.quantity,amount:this.amount,unit_price:this.unit_price,offer:this.offer,supplier_id:this.supplier_id};
|
|
|
+ window.axios.post(url,params).then(res => {
|
|
|
+ if (!res.data.success) {
|
|
|
+ _this.errors = res.data.errors;
|
|
|
+ } else {
|
|
|
+ this.procurements.forEach(function (procurement) {
|
|
|
+ if (procurement.id === res.data.data.id) {
|
|
|
+ procurement.status = res.data.data.status;
|
|
|
+ procurement.amount = res.data.data.amount;
|
|
|
+ procurement.type = res.data.data.type;
|
|
|
+ procurement.quantity = res.data.data.quantity;
|
|
|
+ procurement.unit_price = res.data.data.unit_price;
|
|
|
+ $("#add-quantity").modal('hide');
|
|
|
+ _this.clearData();
|
|
|
+ window.tempTip.setDuration(2000);
|
|
|
+ window.tempTip.showSuccess("已成功发起采购申请");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ window.tempTip.setDuration(3000);
|
|
|
+ window.tempTip.show("网络错误:" + err);
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
}
|