index.blade.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. @extends('layouts.app')
  2. @section('title')采购管理-采购-查询@endsection
  3. @section('content')
  4. @component('procurement.procurement.menu')@endcomponent
  5. <div class="container-fluid" id="list">
  6. <div class="card container-fluid">
  7. @if(Session::has('successTip'))
  8. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  9. @endif
  10. <div class="row">
  11. <div class="col-4">
  12. <div class="row pt-2">
  13. <span class="fa fa-shopping-cart fa-4x offset-md-3" style="color: #4c2584;opacity: 0.3"></span>
  14. <span class="ml-4 mt-2">
  15. <h5 class="font-weight-bold">@{{ countReceive }}</h5>
  16. <p class="text-muted">今日收货次数</p>
  17. </span>
  18. </div>
  19. </div>
  20. <div class="col-4">
  21. <div class="row pt-2">
  22. <span class="fa fa-file-o fa-4x offset-md-3" style="color: #9fcdff;opacity: 0.3"></span>
  23. <span class="ml-4 mt-2">
  24. <h5 class="font-weight-bold">@{{ countProcurement }}</h5>
  25. <p class="text-muted">今日发起采购次数</p>
  26. </span>
  27. </div>
  28. </div>
  29. <div class="col-4">
  30. <div class="row pt-2">
  31. <span class="fa fa-calendar-o fa-4x offset-md-3" style="color: #2ca02c;opacity: 0.3"></span>
  32. <span class="ml-4 mt-2">
  33. <h5 class="font-weight-bold">0</h5>
  34. <p class="text-muted">今日对账金额</p>
  35. </span>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <div id="form_div" class="mt-1"></div>
  41. <div class="row mt-2">
  42. <span class="dropdown ml-3">
  43. <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
  44. :class="[checkData.length>0?'btn-dark text-light':'']"
  45. data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">
  46. 导出Excel
  47. </button>
  48. <div class="dropdown-menu">
  49. <a class="dropdown-item" @click="procurementExport(false)" href="javascript:">导出勾选内容</a>
  50. <a class="dropdown-item" @click="procurementExport(true)" href="javascript:">导出所有页</a>
  51. </div>
  52. </span>
  53. <span class="btn btn-sm btn-outline-info ml-2" @click="addProcurement">新增采购</span>
  54. @can('采购管理-采购-新建')
  55. @include('procurement.procurement._addProcurement')
  56. @endcan
  57. <span class="btn btn-sm btn-outline-success ml-2" @click="addEnquiry">新增询价</span>
  58. @can('采购管理-采购-新建')
  59. @include('procurement.procurement._addEnquiry')
  60. @endcan
  61. <span class="btn btn-sm btn-outline-danger ml-2" @click="addProof">新增打样</span>
  62. @can('采购管理-采购-新建')
  63. @include('procurement.procurement._addProof')
  64. @endcan
  65. @can('采购管理-采购-编辑')
  66. @include('procurement.procurement._addQuantity')
  67. @endcan
  68. <span class="btn btn-sm btn-outline-primary ml-2" @click="createAnew(checkData)">重新发起</span>
  69. </div>
  70. <label for="all" id="cloneCheckAll" class="d-none">
  71. <input id="all" type="checkbox" @click="checkAll($event)">全选
  72. </label>
  73. <table class="table table-sm table-bordered text-nowrap d-none" id="headerRoll"></table>
  74. <table class="table table-sm table-striped table-bordered table-hover text-nowrap card-body mt-2"
  75. id="headerParent">
  76. <tr id="header"></tr>
  77. <tr v-for="(procurement,i) in procurements" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  78. <td>
  79. <input class="checkItem" type="checkbox" :value="procurement.id" v-model="checkData">
  80. </td>
  81. <td class="">@{{ procurement.code }}</td>
  82. <td><span v-if="procurement.owner_material.owner">@{{ procurement.owner_material.owner.name }}</span></td>
  83. <td>@{{ procurement_type[procurement.type] }}</td>
  84. <td><span v-if="procurement.owner_material.owner.customer">@{{ procurement.owner_material.owner.customer.company_name }}</span></td>
  85. <td class="tooltipTarget" style="max-width: 200px;overflow:hidden"><span v-if="procurement.owner_material.material">@{{ procurement.owner_material.material.code }}</span></td>
  86. <td class=""><span v-if="procurement.owner_material.material">@{{ procurement.owner_material.material.name }}</span></td>
  87. <td class=""><span v-if="procurement.owner_material">@{{ procurement.owner_material.size }}</span></td>
  88. <td class=""><span v-if="procurement.owner_material">@{{ procurement.owner_material.special }}</span></td>
  89. <td class=""><span v-if="procurement.owner_material">@{{ procurement.owner_material.specification }}</span></td>
  90. <td>
  91. <div class="align-center text-center" >
  92. <span v-if="procurement.owner_material.file">
  93. <a target='_blank' :href="getDownFileUrl(procurement.owner_material)" class="text-primary text-decoration is-hover" style="cursor: default" >
  94. <i class="fa fa-download"></i>&nbsp;@{{ procurement.owner_material.file.file_name }}
  95. </a>
  96. </span>
  97. <span v-else>-</span>
  98. </div>
  99. </td>
  100. <td>@{{ procurement.quantity }}</td>
  101. <td><span>@{{ procurement.unit_price }}</span></td>
  102. <td><span v-if="procurement.deliver_amount">@{{ procurement.deliver_amount }}</span></td>
  103. <td><span>@{{ procurement.quantity*procurement.unit_price }}</span></td>
  104. <td><span>@{{ procurement_status[procurement.status] }}</span></td>
  105. <td><span v-if="procurement.owner_material.owner.customer">@{{ procurement.owner_material.owner.customer.phone }}</span></td>
  106. <td>
  107. <span v-if="procurement_status[procurement.status]!='订单取消'">
  108. <span class="btn btn-sm btn-outline-danger" v-if="!procurement.supplier_id"
  109. @click="cancel(procurement.id,procurement.type,procurement.code)">取消</span>
  110. <span class="btn btn-sm btn-outline-success" v-if="procurement_type[procurement.type]=='询价单'
  111. /*|| (procurement_type[procurement.type]=='采购单'*/ && !procurement.cost_price"
  112. @click="initiateProcurement(procurement)">发起采购</span>
  113. </span>
  114. </td>
  115. </tr>
  116. </table>
  117. <div class="text-info h5 btn btn">{{$procurements->count()}}/@{{ sum }}</div>
  118. <div>{{$procurements->appends($paginateParams)->links()}}</div>
  119. </div>
  120. @endsection
  121. @section('lastScript')
  122. <script type="text/javascript" src="{{mix('js/queryForm/export.js')}}"></script>
  123. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  124. <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>
  125. <script>
  126. let vue = new Vue({
  127. el: '#list',
  128. data: {
  129. countReceive:{!! $countReceive !!},
  130. countProcurement:{!! $countProcurement !!},
  131. procurements: {!! $procurements->toJson() !!}['data'],
  132. owners: [
  133. @foreach($owners as $owner)
  134. {
  135. name: '{{$owner->id}}', value: '{{$owner->name}}',
  136. ownerMaterials: [
  137. @foreach($owner->ownerMaterials ? $owner->ownerMaterials :[] as $ownerMaterial)
  138. {
  139. id: '{{$ownerMaterial->id}}',
  140. material_code: '{{$ownerMaterial->material_code}}',
  141. material_name: '{{$ownerMaterial->material->name}}',
  142. size: '{{$ownerMaterial->size}}',
  143. special: '{{$ownerMaterial->special}}',
  144. specification: '{{$ownerMaterial->specification}}',
  145. },
  146. @endforeach
  147. ],
  148. @if($owner->customer)customer_name: '{{$owner->customer->name}}',@endif
  149. },
  150. @endforeach
  151. ],
  152. materials: [
  153. @foreach($materials as $material)
  154. {
  155. name: '{{$material->id}}', value: '{{$material->name}}'
  156. },
  157. @endforeach
  158. ],
  159. procurement_type:{!! json_encode(\App\Procurement::type,JSON_UNESCAPED_UNICODE) !!},
  160. procurement_status:{!! json_encode(\App\Procurement::status,JSON_UNESCAPED_UNICODE) !!},
  161. checkData: [],
  162. sum:{!! $procurements->total() !!},
  163. owner_id: '',
  164. owner_material_id: '{{old('owner_material_id')}}',
  165. material_name: '{{old('material_name')}}',
  166. customer_name: '{{old('customer_name')}}',
  167. size: '{{old('size')}}',
  168. special: '{{old('special')}}',
  169. specification: '{{old('specification')}}',
  170. quantity: '{{old('quantity')}}',
  171. amount: '{{old('amount')}}',
  172. unit_price: '{{old('unit_price')}}',
  173. total_price: '{{old('total_price')}}',
  174. procurement_id:'',supplier:'',offer:'',supplier_id:'',
  175. ownerMaterials: [],
  176. errors: {},
  177. selectTr:'',
  178. createdProcurement:{},
  179. },
  180. mounted: function () {
  181. $(".tooltipTarget").tooltip({'trigger': 'hover'});
  182. $('#list').removeClass('d-none');
  183. let data = [
  184. [
  185. {name: 'created_at_start', type: 'dateTime', tip: '选择显示指定日期的起始时间'},
  186. {name: 'created_at_end', type: 'dateTime', tip: '选择显示指定日期的结束时间'},
  187. {
  188. name: 'owner_id', type: 'select_multiple_select', tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的项目'],
  189. placeholder: ['项目', '定位或多选项目'], data: this.owners
  190. },
  191. {
  192. name: 'material_id',
  193. type: 'select_multiple_select',
  194. tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的耗材'],
  195. placeholder: ['耗材', '定位或多选耗材'],
  196. data: this.materials
  197. },
  198. {name: 'company_name', type: 'input', tip: '采购公司:可在两侧增加百分号(%)进行模糊搜索', placeholder: '采购公司'},
  199. ],
  200. ];
  201. this.form = new query({
  202. el: "#form_div",
  203. condition: data,
  204. });
  205. this.form.init();
  206. let column = [
  207. {
  208. name: 'cloneCheckAll', customization: true, type: 'checkAll', column: 'id',
  209. dom: $('#cloneCheckAll').removeClass('d-none'), neglect: true
  210. },
  211. {name: 'code', value: '采购编号', neglect: true},
  212. {name: 'owner_id', value: '项目', class: ''},
  213. {name: 'type', value: '单据类型', class: ''},
  214. {name: 'company_name', value: '采购公司', class: ''},
  215. {name: 'material_code', value: '耗材编号', class: ''},
  216. {name: 'material_name', value: '耗材'},
  217. {name: 'size', value: '尺寸大小', class: ''},
  218. {name: 'special', value: '特殊要求', class: ''},
  219. {name: 'specification', value: '材质规格', class: ''},
  220. {name: '附件', value: '附件', class: ''},
  221. {name: 'quantity', value: '采购数量', neglect: true},
  222. {name: 'unit_price', value: '销售单价(元)', neglect: true},
  223. {name: '', value: '送货数量', neglect: true},
  224. {name: '', value: '销售总价(元)', neglect: true},
  225. {name: '', value: '采购单状态', neglect: true},
  226. {name: '', value: '联系方式', neglect: true},
  227. {name: '', value: '操作', neglect: true},
  228. ];
  229. let _this = this;
  230. setTimeout(function () {
  231. let header = new Header({
  232. el: "#header",
  233. column: column,
  234. data: _this.procurements,
  235. restorationColumn: 'id',
  236. fixedTop: ($('#form_div').height()) + 2,
  237. offset: 0.5,
  238. vue: vue
  239. });
  240. header.init();
  241. }, 0);
  242. },
  243. methods: {
  244. //全选事件
  245. checkAll(e) {
  246. if (e.target.checked) {
  247. this.procurements.forEach((el, i) => {
  248. if (this.checkData.indexOf(el.id) == '-1') {
  249. this.checkData.push(el.id);
  250. }
  251. });
  252. } else {
  253. this.checkData = [];
  254. }
  255. },
  256. addProcurement() {
  257. this.errors = {};
  258. $('#add-procurement').modal('show');
  259. },
  260. addEnquiry() {
  261. this.errors = {};
  262. $('#add-enquiry').modal('show');
  263. },
  264. addProof() {
  265. this.errors = {};
  266. $('#add-proof').modal('show');
  267. },
  268. initiateProcurement(procurement) {
  269. let _this=this;
  270. this.procurement_id=procurement.id;
  271. let url="{{url('procurement/procurement/initiateProcurement')}}";
  272. let params={id:procurement.id};
  273. window.axios.post(url,params).then(res => {
  274. if (res.data.success) {
  275. _this.supplier=res.data.data.supplier.name;
  276. _this.supplier_id=res.data.data.supplier_id;
  277. _this.offer=res.data.data.offer;
  278. if(res.data.data.procurement.quantity)_this.quantity=res.data.data.procurement.quantity;else _this.quantity='';
  279. if(res.data.data.procurement.amount)_this.amount=res.data.data.procurement.amount; else _this.amount='';
  280. $('#add-quantity').modal('show');
  281. } else {
  282. tempTip.setDuration(3000);
  283. tempTip.show(res.data.message);
  284. }
  285. }).catch(err => {
  286. window.tempTip.setDuration(3000);
  287. window.tempTip.show("网络错误:" + err);
  288. });
  289. },
  290. owner_seek: function (e) {
  291. let _this = this;
  292. let $val = e.target.value;
  293. if ($val === '') {
  294. _this.owner_id = '';
  295. } else {
  296. _this.owners.forEach(function (owner) {
  297. if (owner.value.includes($val)) {
  298. _this.owner_id = owner.name;
  299. _this.ownerMaterials = owner.ownerMaterials;
  300. _this.customer_name = owner.customer_name;
  301. }
  302. });
  303. }
  304. },
  305. ownerMaterial: function () {
  306. let _this = this;
  307. _this.ownerMaterials.forEach(function (ownerMaterial) {
  308. if (_this.owner_material_id === ownerMaterial.id) {
  309. _this.material_name = ownerMaterial.material_name;
  310. _this.size = ownerMaterial.size;
  311. _this.special = ownerMaterial.special;
  312. _this.specification = ownerMaterial.specification;
  313. }
  314. })
  315. },
  316. selectOwner: function () {
  317. let _this = this;
  318. _this.owners.forEach(function (owner) {
  319. if (_this.owner_id === owner.name) {
  320. _this.ownerMaterials = owner.ownerMaterials;
  321. _this.customer_name = owner.customer_name;
  322. }
  323. })
  324. },
  325. countTotalPrice: function () {
  326. let _this = this;
  327. if (_this.unit_price === '' || _this.amount === '') _this.total_price = null;
  328. _this.total_price = _this.unit_price * _this.amount;
  329. },
  330. createProcurement() {
  331. let _this = this;
  332. let url = '{{url('procurement/procurement/createProcurement')}}';
  333. let params = {
  334. owner_id: _this.owner_id,
  335. owner_material_id: _this.owner_material_id,
  336. quantity: _this.quantity,
  337. amount: _this.amount,
  338. unit_price: _this.unit_price
  339. };
  340. window.axios.post(url, params).then(function (res) {
  341. if (!res.data.success) {
  342. _this.errors = res.data.errors
  343. } else {
  344. _this.procurements.push(res.data.data);
  345. $("#add-procurement").modal('hide');
  346. _this.clearData();
  347. tempTip.setDuration(3000);
  348. tempTip.showSuccess('新增采购单成功!');
  349. }
  350. }).catch(function (err) {
  351. tempTip.setDuration(3000);
  352. tempTip.show('新增采购单失败!网络错误:' + err);
  353. });
  354. },
  355. createEnquiry() {
  356. let _this = this;
  357. let url = '{{url('procurement/procurement/createEnquiry')}}';
  358. let params = {owner_id: _this.owner_id, owner_material_id: _this.owner_material_id};
  359. window.axios.post(url, params).then(function (res) {
  360. if (!res.data.success) {
  361. _this.errors = res.data.errors;
  362. } else {
  363. _this.procurements.push(res.data.data);
  364. $("#add-enquiry").modal('hide');
  365. _this.clearData();
  366. tempTip.setDuration(3000);
  367. tempTip.showSuccess('新增询价单成功!');
  368. }
  369. }).catch(function (err) {
  370. tempTip.setDuration(3000);
  371. tempTip.show('新增询价单失败!网络错误:' + err);
  372. });
  373. },
  374. createProof() {
  375. let _this = this;
  376. let url = '{{url('procurement/procurement/createProof')}}';
  377. let params = {owner_id: _this.owner_id, owner_material_id: _this.owner_material_id};
  378. window.axios.post(url, params).then(function (res) {
  379. if (!res.data.success) {
  380. _this.errors = res.data.errors;
  381. } else {
  382. _this.procurements.push(res.data.data);
  383. $("#add-proof").modal('hide');
  384. _this.clearData();
  385. tempTip.setDuration(3000);
  386. tempTip.showSuccess('新增打样单成功!');
  387. }
  388. }).catch(function (err) {
  389. tempTip.setDuration(3000);
  390. tempTip.show('新增打样单失败!网络错误:' + err);
  391. });
  392. },
  393. clearData() {
  394. this.owner_id = '';this.owner_material_id = '';
  395. this.material_name = '';this.customer_name = '';
  396. this.size = '';this.special = '';
  397. this.specification = '';this.quantity = '';
  398. this.amount = '';this.unit_price = '';
  399. this.total_price = '';this.procurement_id='';
  400. this.supplier_id='',this.offer='';
  401. },
  402. procurementExport(selectAll) {
  403. let url = '{{url('procurement/procurement/procurementExport')}}';
  404. let token = '{{ csrf_token() }}';
  405. excelExport(selectAll, this.checkData, url, this.sum, token);
  406. },
  407. cancel(id, type, code) {
  408. window.tempTip.confirm('确定取消' + this.procurement_type[type] + ' ' + code, () => {
  409. window.axios.get("{{url('procurement/procurement/cancel')}}/" + id)
  410. .then(res => {
  411. if (res.data.success) {
  412. this.procurements.forEach(function (procurement) {
  413. if (procurement.id === res.data.data.id) {
  414. procurement.status = res.data.data.status;
  415. window.tempTip.setDuration(2000);
  416. window.tempTip.showSuccess("已成功取消该条采购申请");
  417. }
  418. })
  419. } else {
  420. tempTip.setDuration(3000);
  421. tempTip.show(res.data.message);
  422. }
  423. }).catch(err => {
  424. window.tempTip.setDuration(3000);
  425. window.tempTip.show("网络错误:" + err);
  426. });
  427. });
  428. },
  429. submitProcurement() {
  430. let _this=this;
  431. let id=this.procurement_id;
  432. if (!id)return;
  433. let url="{{url('procurement/procurement/submitProcurement')}}";
  434. let params={id:id,quantity:this.quantity,amount:this.amount,unit_price:this.unit_price,offer:this.offer,supplier_id:this.supplier_id};
  435. window.axios.post(url,params).then(res => {
  436. if (!res.data.success) {
  437. _this.errors = res.data.errors;
  438. } else {
  439. this.procurements.forEach(function (procurement) {
  440. if (procurement.id === res.data.data.id) {
  441. procurement.status = res.data.data.status;
  442. procurement.amount = res.data.data.amount;
  443. procurement.type = res.data.data.type;
  444. procurement.quantity = res.data.data.quantity;
  445. procurement.unit_price = res.data.data.unit_price;
  446. $("#add-quantity").modal('hide');
  447. _this.clearData();
  448. window.tempTip.setDuration(2000);
  449. window.tempTip.showSuccess("已成功发起采购申请");
  450. }
  451. })
  452. }
  453. }).catch(err => {
  454. window.tempTip.setDuration(3000);
  455. window.tempTip.show("网络错误:" + err);
  456. });
  457. },
  458. //从新创建procurement
  459. createAnew(checkData){
  460. let _this=this;
  461. let url="{{url('procurement/procurement/createAnew')}}";
  462. let params={checkData:checkData};
  463. window.axios.post(url,params).then(res => {
  464. if (!res.data.success) {
  465. window.tempTip.setDuration(3000);
  466. window.tempTip.show(res.data.message);
  467. } else {
  468. res.data.data.forEach(function (procurement) {
  469. _this.procurements.push(procurement);
  470. });
  471. _this.checkData=[];
  472. window.tempTip.setDuration(2000);
  473. window.tempTip.showSuccess("从新发起成功");
  474. }
  475. }).catch(err => {
  476. window.tempTip.setDuration(3000);
  477. window.tempTip.show("网络错误:" + err);
  478. });
  479. },
  480. getDownFileUrl(ownerMaterial){
  481. return '{{ url("maintenance/ownerMaterial/downFile?file=")}}'+ownerMaterial.file.url+'&name='+ownerMaterial.file.file_name;
  482. },
  483. }
  484. });
  485. </script>
  486. @endsection