index.blade.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. @extends('layouts.app')
  2. @section('title')查询-作业-计费模型@endsection
  3. @section('content')
  4. <div id="nav2">
  5. @component('maintenance.menu')@endcomponent
  6. @component('maintenance.priceModel.operation.menu')@endcomponent
  7. </div>
  8. <div class="container-fluid mt-2" id="container">
  9. @include("maintenance.priceModel.operation._addItemModal")
  10. @include("maintenance.priceModel.operation._addFeature")
  11. <div id="form_div"></div>
  12. @if(Session::has('successTip'))
  13. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  14. @endif
  15. <table class="table table-hover table-striped text-nowrap">
  16. <tr>
  17. <th>序号</th>
  18. <th>操作</th>
  19. <th>名称</th>
  20. <th>类型</th>
  21. <th>策略</th>
  22. <th>项目</th>
  23. <th>优先级</th>
  24. <th>按单单价</th>
  25. <th>按单减免</th>
  26. <th>特征</th>
  27. <th>备注</th>
  28. <th>录入时间</th>
  29. <th>操作</th>
  30. </tr>
  31. <tr v-for="(model,i) in models" :id="'model-'+model.id" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  32. <td>@{{ i+1 }}</td>
  33. <td>
  34. <button v-if="thisId != model.id" class="btn btn-sm btn-info text-white" @click="showDetail(model.id,model.operationType,i)">维护详情</button>
  35. <button v-if="thisId == model.id" class="btn btn-sm btn-dark" @click="thisId = ''">关闭详情</button>
  36. </td>
  37. <td>@{{ model.name }}</td>
  38. <td>@{{ model.operationType }}</td>
  39. <td>@{{ model.strategy }}</td>
  40. <td><small v-for="owner in model.owners" class="m-0 font-weight-bold">@{{ owner.name }}<br></small></td>
  41. <td>@{{ model.priority }}</td>
  42. <td>@{{ model.totalPrice ? model.totalPrice : '/' }}</td>
  43. <td>
  44. <span v-if="model.totalPrice"><small v-for="(price,i) in model.totalDiscountPrice">@{{ model.discountCount[i] }}单/@{{ price }}元<br></small></span>
  45. <span v-else>/</span>
  46. </td>
  47. <td>@{{ model.feature }}</td>
  48. <td><div class="text-overflow-warp-200 warp-min-200">@{{ model.remark }}</div></td>
  49. <td>@{{ model.createdAt }}</td>
  50. <td>
  51. @can("计费模型-作业-编辑")<button type="button" class="btn btn-sm btn-outline-info" @click="edit(model.id)">编辑</button>@endcan
  52. @can("计费模型-作业-删除")<button type="button" class="btn btn-sm btn-outline-danger" @click="delModel(model.id,i)">删除</button>@endcan
  53. </td>
  54. </tr>
  55. <tr id="detail" v-show="thisId">
  56. <td></td>
  57. <td colspan="9">
  58. <table class="table table-sm table-bordered">
  59. <tr class="text-success">
  60. <th>操作</th>
  61. <th>计费策略</th>
  62. <th>起步数</th>
  63. <th>单位</th>
  64. <th>单价</th>
  65. <th>减免</th>
  66. <th>优先级</th>
  67. <th class="text-center">特征</th>
  68. <th></th>
  69. </tr>
  70. <tr v-if="items[thisId] && items[thisId].length == 0">
  71. <td colspan="8">
  72. @can("计费模型-作业-编辑")<button class="btn btn-sm btn-outline-info" @click="showAddItemModal()">新增</button>@endcan
  73. </td>
  74. </tr>
  75. <tr v-for="(item,i) in items[thisId]">
  76. <td>
  77. <span v-if="updateDetailId != item.id">
  78. @can("计费模型-作业-编辑")<button class="btn btn-sm btn-outline-info" @click="showAddItemModal()" v-if="i==0">新增</button>
  79. <button class="btn btn-sm btn-outline-info" @click="showUpdateDetail(item.id)">修改</button>@endcan
  80. </span>
  81. <span v-else>
  82. <button class="btn btn-sm btn-success" @click="submitUpdateDetail(item)">确定</button>
  83. <button class="btn btn-sm btn-danger" @click="updateDetailId = ''">取消</button>
  84. </span>
  85. </td>
  86. <td>@{{ item.strategy }}</td>
  87. <td>
  88. <label v-if="updateDetailId == item.id">
  89. <input type="number" min="0" id="detailAmount" class="form-control form-control-sm"
  90. :value="item.amount">
  91. </label>
  92. <label v-else>@{{ item.amount }}</label>
  93. </td>
  94. <td>
  95. <label v-if="updateDetailId == item.id">
  96. <select class="form-control form-control-sm" id="detailUnit">
  97. <option v-for="unit in units" :value="unit.id" v-if="unit.id==item.unit_id" selected>@{{ unit.name }}</option>
  98. <option v-for="unit in units" :value="unit.id" v-if="unit.id!=item.unit_id">@{{ unit.name }}</option>
  99. </select>
  100. </label>
  101. <label v-else>@{{ item.unit ? item.unit.name : '' }}</label>
  102. </td>
  103. <td>
  104. <label v-if="updateDetailId == item.id">
  105. <input type="number" min="0" step="0.001" id="detailUnitPrice" class="form-control form-control-sm"
  106. :value="item.unit_price">
  107. </label>
  108. <label v-else>@{{ item.unit_price }}</label>
  109. </td>
  110. <td>
  111. <span v-if="item.discount_price.length>0"><small v-for="(price,i) in item.discount_price">@{{ models[thisIndex].discountCount[i] }}单/@{{ price }}元<br></small></span>
  112. <span v-else>/</span>
  113. </td>
  114. <td>
  115. <label v-if="updateDetailId == item.id">
  116. <input type="number" min="0" id="detailPriority" class="form-control form-control-sm"
  117. :value="item.priority">
  118. </label>
  119. <label v-else>@{{ item.priority }}</label>
  120. </td>
  121. <td>@{{ item.featureFormat }}</td>
  122. <td>
  123. @can("计费模型-作业-编辑")<button class="btn btn-sm btn-success" v-if="item.strategy == '特征'" @click="showAddFeatureModal(i,item.feature)">维护特征</button>@endcan
  124. </td>
  125. </tr>
  126. </table>
  127. </td>
  128. </tr>
  129. </table>
  130. </div>
  131. @stop
  132. @section("lastScript")
  133. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  134. <script>
  135. new Vue({
  136. el:"#container",
  137. data:{
  138. models : [
  139. @foreach($models as $model)
  140. {
  141. id : "{{$model->id}}",
  142. operationType : "{{$model->operation_type}}",
  143. name : "{{$model->name}}",
  144. strategy : "{{$model->strategy}}",
  145. feature : "{{$model->featureFormat}}",
  146. remark : "{{$model->remark}}",
  147. priority : "{{$model->priority}}",
  148. discountCount : "{{$model->discount_count}}" ? "{{$model->discount_count}}".split(",") : ["/"],
  149. totalPrice : "{{$model->total_price}}",
  150. totalDiscountPrice : "{{$model->total_discount_price}}" ? "{{$model->total_discount_price}}".split(",") : ["/"],
  151. createdAt : "{{$model->created_at}}",
  152. owners : {!! $model->owners !!},
  153. },
  154. @endforeach
  155. ],
  156. owners : [
  157. @foreach($owners as $owner)
  158. {name:"{{$owner->id}}",value:"{{$owner->name}}"},
  159. @endforeach
  160. ],
  161. thisId : "",
  162. thisIndex : "",
  163. items : [],
  164. updateDetailId : '',
  165. units : null,
  166. type : {!! json_encode(\App\Feature::type,JSON_UNESCAPED_UNICODE) !!},
  167. logic : ['包含','不包含','等于'],
  168. item : {
  169. "strategy" : '特征',
  170. "amount" : "",
  171. "unit_id" : "",
  172. "unit_price" : "",
  173. "priority" : 0,
  174. },
  175. features : [],
  176. existStrategy:{default:false,starting:false},
  177. selectTr:''
  178. },
  179. mounted(){
  180. let data=[
  181. [
  182. {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的项目'],
  183. placeholder:['项目','定位或多选项目'],data:this.owners},
  184. {name: 'name', type: 'input', tip: '价格名称:可在左侧增加百分号(%)进行模糊搜索', placeholder: '价格名称'},
  185. ]
  186. ];
  187. this.form = new query({
  188. el:"#form_div",
  189. condition:data,
  190. });
  191. this.form.init();
  192. },
  193. methods:{
  194. showDetail(id,type,index){
  195. if (this.items[id]){
  196. this.thisId = id;
  197. $("#model-"+id).after($("#detail"));
  198. return;
  199. }
  200. window.axios.post("{{url('maintenance/priceModel/operation/getItems')}}",{id:id,type:type})
  201. .then(res=>{
  202. if (res.data.success){
  203. res.data.data.forEach((item,i)=>{
  204. res.data.data[i].discount_price = item.discount_price ? item.discount_price.split(",") : [];
  205. });
  206. this.items[id] = res.data.data;
  207. this.thisId = id;
  208. this.thisIndex = index;
  209. $("#model-"+id).after($("#detail"));
  210. return;
  211. }
  212. window.tempTip.setDuration(3000);
  213. window.tempTip.show(res.data.data);
  214. }).catch(err=>{
  215. window.tempTip.setDuration(3000);
  216. window.tempTip.show("网络错误:"+err);
  217. });
  218. },
  219. showUpdateDetail(id){
  220. if (!this.units)this._getUnits();
  221. this.updateDetailId = id;
  222. },
  223. _getUnits(){
  224. window.axios.post("{{url('maintenance/unit/getUnits')}}")
  225. .then(res=>{
  226. if (res.data.success){
  227. this.units = res.data.data;
  228. return;
  229. }
  230. window.tempTip.setDuration(3000);
  231. window.tempTip.show(res.data.data);
  232. }).catch(err=>{
  233. window.tempTip.setDuration(3000);
  234. window.tempTip.show("网络错误:"+err);
  235. });
  236. },
  237. submitUpdateDetail(item){
  238. let amount = $("#detailAmount").val();
  239. let unit_id = $("#detailUnit").val();
  240. let unit_price = $("#detailUnitPrice").val();
  241. let priority = $("#detailPriority").val();
  242. window.axios.post("{{url('maintenance/priceModel/operation/updateItem')}}",
  243. {id:item.id,amount:amount,unit_id:unit_id,unit_price:unit_price,priority:priority})
  244. .then(res=>{
  245. if (res.data.success){
  246. item.amount = amount;
  247. if (item.unit_id != unit_id){
  248. this.units.some((unit)=>{
  249. if (unit_id == unit.id){
  250. item.unit = unit;
  251. return true;
  252. }
  253. });
  254. item.unit_id = unit_id;
  255. }
  256. item.unit_price = unit_price;
  257. item.priority = priority;
  258. this.updateDetailId = '';
  259. window.tempTip.setDuration(2000);
  260. window.tempTip.showSuccess("修改成功");
  261. return;
  262. }
  263. window.tempTip.setDuration(3000);
  264. window.tempTip.show(res.data.data);
  265. }).catch(err=>{
  266. window.tempTip.setDuration(3000);
  267. window.tempTip.show("网络错误:"+err);
  268. });
  269. },
  270. showAddItemModal(){
  271. if (!this.units)this._getUnits();
  272. let startingSign = true;
  273. let defaultSign = true;
  274. this.items[this.thisId].forEach(item=>{
  275. if (item.strategy === '默认')defaultSign = false;
  276. if (item.strategy === '起步')startingSign = false;
  277. });
  278. if (!startingSign)this.existStrategy.starting = true;
  279. if (!defaultSign)this.existStrategy.default = true;
  280. $("#addItem").modal("show");
  281. },
  282. submitItem(){
  283. if (!this.thisId || !this.item.strategy || !this.item.unit_id || !this.item.unit_price){
  284. window.tempTip.setDuration(3000);
  285. window.tempTip.show("计费策略,单位,单价为必填项");
  286. return;
  287. }
  288. window.axios.post("{{url('maintenance/priceModel/operation/createItem')}}",
  289. {owner_price_operation_id:this.thisId,strategy:this.item.strategy,amount:this.item.amount,unit_id:this.item.unit_id,unit_price:this.item.unit_price,priority:Number(this.item.priority)})
  290. .then(res=>{
  291. if (res.data.success){
  292. this.items[this.thisId].unshift(res.data.data);
  293. this.$forceUpdate();
  294. window.tempTip.setDuration(2000);
  295. window.tempTip.setIndex(1099);
  296. window.tempTip.showSuccess("新增出库策略成功");
  297. $("#addItem").modal("hide");
  298. return;
  299. }
  300. window.tempTip.setDuration(3000);
  301. window.tempTip.setIndex(1099);
  302. window.tempTip.show(res.data.data);
  303. }).catch(err=>{
  304. window.tempTip.setDuration(3000);
  305. window.tempTip.show("网络错误:"+err);
  306. });
  307. },
  308. showAddFeatureModal(index,feature){
  309. window.axios.post("{{url('maintenance/priceModel/operation/getFeatures')}}", {feature:feature})
  310. .then(res=>{
  311. if (res.data.success){
  312. this.features = res.data.data;
  313. if (this.features.length === 0)this.addFeature();
  314. this.thisIndex = index;
  315. $("#addFeatureModal").modal("show");
  316. return;
  317. }
  318. window.tempTip.setDuration(3000);
  319. window.tempTip.show(res.data.data);
  320. }).catch(err=>{
  321. window.tempTip.setDuration(3000);
  322. window.tempTip.show("网络错误:"+err);
  323. });
  324. },
  325. addFeature(){
  326. this.features.push({
  327. "strategyGroupStartSign": false,
  328. "calculation" : "",
  329. "type" : "",
  330. "id" : "", //特征ID
  331. "logic" : "", //特征逻辑
  332. "describe" : "", //特征信息
  333. "strategyGroupEndSign" : false,
  334. });
  335. },
  336. delFeature(index) {
  337. this.$delete(this.features,index);
  338. },
  339. submitFeature(){
  340. window.axios.post("{{url('maintenance/priceModel/operation/addFeature')}}",
  341. {id:this.items[this.thisId][this.thisIndex].id,features:this.features})
  342. .then(res=>{
  343. if (res.data.success){
  344. this.items[this.thisId][this.thisIndex].featureFormat = res.data.data.featureFormat;
  345. this.items[this.thisId][this.thisIndex].feature = res.data.data.feature;
  346. this.$forceUpdate();
  347. $("#addFeatureModal").modal("hide");
  348. window.tempTip.setDuration(2000);
  349. window.tempTip.setIndex(1099);
  350. window.tempTip.showSuccess("已更新特征");
  351. return;
  352. }
  353. window.tempTip.setDuration(3000);
  354. window.tempTip.setIndex(1099);
  355. window.tempTip.show(res.data.data);
  356. }).catch(err=>{
  357. window.tempTip.setDuration(3000);
  358. window.tempTip.setIndex(1099);
  359. window.tempTip.show("网络错误:"+err);
  360. });
  361. },
  362. delModel(id,index){
  363. window.tempTip.confirm("确定要删除该作业计费吗?",()=>{
  364. window.axios.delete("{{url('maintenance/priceModel/operation')}}/"+id)
  365. .then(res=>{
  366. if (res.data.success){
  367. this.$delete(this.models,index);
  368. window.tempTip.setDuration(2000);
  369. window.tempTip.showSuccess("已成功删除该条作业计费");
  370. return;
  371. }
  372. window.tempTip.setDuration(3000);
  373. window.tempTip.show(res.data.data);
  374. }).catch(err=>{
  375. window.tempTip.setDuration(3000);
  376. window.tempTip.show("网络错误:"+err);
  377. });
  378. });
  379. },
  380. edit(id){
  381. window.location.href = "{{url('maintenance/priceModel/operation')}}/"+id+"/edit";
  382. }
  383. },
  384. });
  385. </script>
  386. @stop