dispatch-info.blade.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. @extends('layouts.base')
  2. @section('title', '编辑配送模板')
  3. @section('content')
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}"/>
  5. <div class="all">
  6. <div id="app" v-cloak>
  7. <div class="vue-crumbs">
  8. <a @click="goParent">配送模板</a> > 配送方式设置
  9. </div>
  10. <div class="vue-main">
  11. <div class="vue-main-title">
  12. <div class="vue-main-title-left"></div>
  13. <div class="vue-main-title-content">配送方式设置</div>
  14. </div>
  15. <div class="vue-main-form">
  16. <el-form ref="form" :model="form" :rules="rules" label-width="15%">
  17. <el-form-item label="请选择中台供应链" prop="middleground_configuration_id">
  18. <el-select v-model="middleground_configuration_id" placeholder="请选择供应链" clearable remote filterable >
  19. <el-option :disabled="id != 0" v-for="item in middleground_configuration" :key="item.id" :label="item.title" :value="item.id"></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="配送方式名称" prop="dispatch_name">
  23. <el-input v-model="form.dispatch_name" style="width:70%;"></el-input>
  24. </el-form-item>
  25. <el-form-item label="计算方式" prop="calculate_type">
  26. <el-radio v-model.number="form.calculate_type" :label="0">按重量计费</el-radio>
  27. <el-radio v-model.number="form.calculate_type" :label="1">按件计费</el-radio>
  28. </el-form-item>
  29. <el-form-item label="配送区域" prop="explain_content">
  30. <table class="el-table" style="width:90%">
  31. <tr style="border-bottom:1px solid #EBEEF5">
  32. <th style="width:40%">运送到</th>
  33. <th>[[form.calculate_type==1?'首件(个)':'首重(克)']]</th>
  34. <th>[[form.calculate_type==1?'运费(元)':'首费(元)']]</th>
  35. <th>[[form.calculate_type==1?'续件(个)':'续重(克)']]</th>
  36. <th>续费(元)</th>
  37. <th style="width:80px">操作</th>
  38. </tr>
  39. <tr v-for="(item,index) in data" :key="index">
  40. <td>
  41. <!-- <div style="font-size:12px;font-weight:600;line-height:18px;margin-right: 15px">
  42. <span v-for="(item1,index1) in item.areas" :key="index1">[[item1]];</span>
  43. </div> -->
  44. <div style="font-size:12px;font-weight:600;line-height:18px;margin-right: 15px">
  45. [[item.areas]]
  46. </div>
  47. <el-button size="small" @click="openVisible('data',index)">选择区域</el-button>
  48. </td>
  49. <td>
  50. <el-input v-model="item.first_weight" style="width:80%"></el-input>
  51. </td>
  52. <td>
  53. <el-input v-model="item.first_weight_price" style="width:80%"></el-input>
  54. </td>
  55. <td>
  56. <el-input v-model="item.another_weight" style="width:80%"></el-input>
  57. </td>
  58. <td>
  59. <el-input v-model="item.another_weight_price" style="width:80%"></el-input>
  60. </td>
  61. <td>
  62. <el-link :underline="false" @click="delList('data',index)" class="vue-assist-color"> 删除</el-link>
  63. </td>
  64. </tr>
  65. </table>
  66. <el-button type="primary" plain icon="el-icon-plus" size="small" @click="addList">新增配送区域</el-button>
  67. <div class="tip" v-if="form.calculate_type==1">根据件数来计算运费,当物品不足《首件数量》时,按照《首件费用》计算,超过部分按照《续件数量》和《续件费用》乘积来计算</div>
  68. <div class="tip" v-else>根据重量来计算运费,当物品不足《首重重量》时,按照《首重费用》计算,超过部分按照《续重重量》和《续重费用》乘积来计算</div>
  69. </el-form-item>
  70. </el-form>
  71. </div>
  72. </div>
  73. <!-- 分页 -->
  74. <div class="vue-page">
  75. <div class="vue-center">
  76. <el-button type="primary" @click="submitForm('form')">保存设置</el-button>
  77. <el-button @click="goBack">返回</el-button>
  78. </div>
  79. </div>
  80. <el-dialog title="请选择地区" :visible.sync="centerDialogVisible" center v-if="chooseIndex!=-1&&showVisible" :before-close="beforeClose">
  81. <el-tree
  82. v-loading="loading"
  83. :props="props"
  84. node-key="id"
  85. :default-checked-keys="chooseItem.area_ids"
  86. :default-expanded-keys="chooseItem.province_ids"
  87. show-checkbox
  88. lazy
  89. @check-change="checkAreas"
  90. ref="addressTree"
  91. :data="treeData"
  92. :load="loadNode"
  93. style="height:500px;overflow:auto"
  94. >
  95. </el-tree>
  96. <span slot="footer" class="dialog-footer">
  97. <el-button @click="beforeClose">取 消</el-button>
  98. <el-button type="primary" @click="saveAreas">确 定</el-button>
  99. </span>
  100. </el-dialog>
  101. </div>
  102. </div>
  103. <script>
  104. var app = new Vue({
  105. el:"#app",
  106. delimiters: ['[[', ']]'],
  107. name: 'test',
  108. data() {
  109. let id = {!! $id?:0 !!};
  110. let middleground_configuration_id = {!! $middleground_configuration_id?:0 !!}
  111. return{
  112. id:id,
  113. submit_link:'',
  114. data:[],//按重量计费-区域数据
  115. middleground_configuration:[],
  116. middleground_configuration_id:middleground_configuration_id,
  117. form:{
  118. calculate_type:0,
  119. },
  120. chooseIndex:-1,
  121. chooseName:'weight',
  122. chooseItem:{},
  123. chooseAreas:[],
  124. chooseAreaIds:[],
  125. chooseProvinceIds:[],
  126. centerDialogVisible:false,
  127. showVisible:false,
  128. props: {
  129. label: 'areaname',
  130. children: 'children',
  131. isLeaf: 'isLeaf'
  132. },
  133. loading: false,
  134. treeData: [],
  135. rules:{
  136. dispatch_name:{ required: true, message: '请输入配送方式名称'}
  137. },
  138. }
  139. },
  140. created() {
  141. },
  142. mounted() {
  143. if(!this.id) {
  144. this.getMiddlegroundConfiguration(1);
  145. this.submit_link = '{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-dispatch.add') !!}';
  146. }
  147. else {
  148. this.getMiddlegroundConfiguration(2);
  149. this.submit_link = '{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-dispatch.edit') !!}';
  150. }
  151. },
  152. methods: {
  153. getMiddlegroundConfiguration(type){
  154. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  155. this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.middleground-configuration.get-middleground-configurations') !!}').then(function (response) {
  156. if (response.data.result) {
  157. this.middleground_configuration = response.data.data;
  158. if(type == 1){
  159. this.middleground_configuration_id = this.middleground_configuration[0].id;
  160. }else{
  161. this.getData();
  162. }
  163. } else {
  164. this.$message({message: response.data.msg, type: 'error'});
  165. }
  166. loading.close();
  167. }, function (response) {
  168. this.$message({message: response.data.msg, type: 'error'});
  169. loading.close();
  170. })
  171. },
  172. getData() {
  173. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  174. this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-dispatch.find-express-template') !!}', {'id':this.id,'middleground_configuration_id':this.middleground_configuration_id}).then(function (response) {
  175. if (response.data.result){
  176. this.form = {
  177. ...response.data.data.data,
  178. };
  179. for(var i in response.data.data.data.items) {
  180. this.data.push(response.data.data.data.items[i])
  181. }
  182. }
  183. else {
  184. this.$message({message: response.data.msg,type: 'error'});
  185. }
  186. loading.close();
  187. },function (response) {
  188. this.$message({message: response.data.msg,type: 'error'});
  189. loading.close();
  190. }
  191. );
  192. },
  193. goParent() {
  194. window.location.href = `{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-dispatch.index') !!}`;
  195. },
  196. submitForm(formName) {
  197. this.form.middleground_configuration_id = this.middleground_configuration_id;
  198. let json = this.form;
  199. json.data = this.data;
  200. let json1 = {
  201. dispatch:json
  202. }
  203. if(this.id) {
  204. json1.id = this.id
  205. }
  206. this.$refs[formName].validate((valid) => {
  207. if (valid) {
  208. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  209. this.$http.post(this.submit_link,json1).then(response => {
  210. if (response.data.result) {
  211. this.$message({type: 'success',message: '操作成功!'});
  212. this.goBack();
  213. } else {
  214. this.$message({message: response.data.msg,type: 'error'});
  215. }
  216. loading.close();
  217. },response => {
  218. loading.close();
  219. });
  220. }
  221. else {
  222. return false;
  223. }
  224. });
  225. },
  226. addList() {
  227. this.data.push(
  228. {areas:"",area_ids:"",province_ids:[],first_piece:this.form.first_piece,first_piece_price:this.form.first_piece_price,another_piece:this.form.another_piece,another_piece_price:this.form.another_piece_price}
  229. )
  230. },
  231. delList(name,index) {
  232. if(name == "data") {
  233. this.data.splice(index,1);
  234. }
  235. },
  236. handleClose(area) {
  237. this.form.areas.splice(this.form.areas.indexOf(area), 1);
  238. },
  239. openVisible(name,index) {
  240. this.centerDialogVisible = true;
  241. this.showVisible = true;
  242. this.chooseName = name;
  243. this.chooseIndex = index;
  244. this.chooseItem = {};
  245. this.chooseItem = JSON.parse(JSON.stringify(this.data[index]));
  246. this.chooseItem.area_ids = this.data[index].area_ids.split(";");
  247. this.chooseItem.area_ids.forEach((item,index) => {
  248. this.chooseItem.area_ids[index] = Number(item)
  249. });
  250. this.chooseItem.areas = this.data[index].areas.split(";");
  251. },
  252. loadNode(node, resolve) {
  253. this.loading = true;
  254. if (!node.data.id) {
  255. //省份
  256. node.data.id = 0;
  257. // getRegion
  258. {{-- {!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-dispatch.index') !!}--}}
  259. {{-- !! yzWebUrl('area.list', ['parent_id'=> 0]) !!}--}}
  260. this.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-dispatch.get-region') !!}",{'parent_id':0,'middleground_configuration_id':this.middleground_configuration_id}).then(response => {
  261. response.data.data.forEach(function (province) {
  262. province.isLeaf = false;
  263. });
  264. // response.data.data.splice(-3,3) //因为中台没有后三个 保持与中台一致
  265. resolve(response.data.data);
  266. this.loading = false;
  267. }, response => {
  268. });
  269. } else {
  270. //城市
  271. this.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.cloud.cloud-dispatch.get-region') !!}",{'parent_id':node.data.id,'middleground_configuration_id':this.middleground_configuration_id}).then(response => {
  272. //城市没有子节点
  273. response.data.data.forEach(function (city) {
  274. city.isLeaf = true;
  275. })
  276. resolve(response.data.data);
  277. // 载入数据后,刷新已选中
  278. this.loading = false;
  279. }, response => {
  280. });
  281. }
  282. },
  283. checkAreas(node,checked,children) {
  284. if(node.isLeaf){
  285. return;
  286. }
  287. if(checked){
  288. if(!this.chooseItem.province_ids) {
  289. this.chooseItem.province_ids = [];
  290. }
  291. this.chooseItem.province_ids.push(node.id)
  292. }
  293. },
  294. saveAreas() {
  295. let areas = [];
  296. let area_ids = [];
  297. let province_ids = [];
  298. this.$refs.addressTree.getCheckedNodes().forEach(function (node) {
  299. if (node.level == 1) {
  300. province_ids.push(node.id);
  301. } else if (node.level == 2) {
  302. area_ids.push(node.id);
  303. areas.push(node.areaname)
  304. }
  305. });
  306. this.$refs.addressTree.getHalfCheckedNodes().forEach(function (node) {
  307. if (node.level == 1) {
  308. province_ids.push(node.id);
  309. }
  310. });
  311. this.data[this.chooseIndex].area_ids = area_ids.join(";");
  312. this.data[this.chooseIndex].areas = areas.join(";");
  313. this.data[this.chooseIndex].province_ids = province_ids;
  314. this.centerDialogVisible = false
  315. this.showVisible = false;
  316. },
  317. beforeClose() {
  318. this.centerDialogVisible = false;
  319. this.showVisible = false;
  320. },
  321. goBack() {
  322. history.go(-1)
  323. },
  324. },
  325. })
  326. </script>
  327. @endsection