freight-set.blade.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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. <style>
  6. .el-tabs__item,.is-top{font-size:16px}
  7. .el-tabs__active-bar { height: 3px;}
  8. .el-scrollbar__wrap{
  9. overflow-x: hidden;
  10. }
  11. .firstCate{
  12. width: 100%;
  13. text-align: center;
  14. }
  15. .firstCate .el-checkbox__inner{
  16. display: none;
  17. }
  18. .el-checkbox-group {
  19. text-align: left;
  20. }
  21. .el-checkbox {
  22. padding-left: 20px;
  23. text-align: left;
  24. }
  25. .active-no-color {
  26. color: #666;
  27. }
  28. .checkbox-pane {
  29. display: flex;
  30. }
  31. .checkbox-color {
  32. color: #29BA9C;
  33. }
  34. .checkbox-name {
  35. line-height: 19px;
  36. margin-left: 5px;
  37. cursor: pointer;
  38. }
  39. .el-select-dropdown__list {
  40. margin-bottom: 20px;
  41. }
  42. .category-style {
  43. text-align:left;
  44. background-color:#eff3f6;
  45. border:3px solid #eff3f6;
  46. padding-left:5px;
  47. }
  48. .scrollbar-style {
  49. height:400px;
  50. border:3px solid #eff3f6;
  51. width:auto;
  52. }
  53. </style>
  54. <div class="all">
  55. <div id="app" v-cloak>
  56. <div class="vue-crumbs">
  57. <a @click="goParent">折扣运费设置</a> > 折扣邮费设置
  58. </div>
  59. <div class="vue-main">
  60. <div class="vue-main-title">
  61. <div class="vue-main-title-left"></div>
  62. <div class="vue-main-title-content">折扣邮费设置</div>
  63. </div>
  64. <div class="vue-main-form">
  65. <el-form ref="form" :model="form" :rules="rules" label-width="15%">
  66. <el-form-item label="选择分类" prop="classification">
  67. <el-input :value="classification" style="width:60%;" disabled></el-input>
  68. <el-button type="primary" @click="visDia()">选择分类</el-button>
  69. <p class="help-block">只能选择商品的二级、三级分类</p>
  70. <el-dialog title="选择分类" :visible.sync="dialogTableVisible" @close="closeDialog">
  71. <el-select
  72. default-first-option
  73. value-key="id"
  74. v-model="search_categorys"
  75. filterable
  76. multiple
  77. remote
  78. reserve-keyword
  79. :remote-method="loadCategorys"
  80. :loading="loading"
  81. style="width:100%;margin-bottom:20px">
  82. <el-option v-for="item in categorys" :key="item.id" :label="'[ID:'+item.id+'][分类:'+item.name+']'" :value="item"></el-option>
  83. </el-select>
  84. <el-row :gutter="0">
  85. <el-col :span="8" >
  86. <div class="category-style">一级分类</div>
  87. <el-scrollbar class="scrollbar-style">
  88. <el-checkbox-group v-model="checkedFirstCate" class="firstCate" @change="loadSecond">
  89. <el-checkbox style="display:block;" v-for="(item, index) in firstCate"
  90. :label="item.id" :value="item.id" name="type">[[item.name]]
  91. </el-checkbox>
  92. </el-checkbox-group>
  93. </el-scrollbar>
  94. </el-col>
  95. <el-col :span="8" >
  96. <div class="category-style">二级分类</div>
  97. <el-scrollbar class="scrollbar-style">
  98. <!-- <el-checkbox-group v-model="checkedSecondCate" style="width:100%;text-align: center" @change="loadThird"> -->
  99. <div v-for="(item, index) in secondCate" class="checkbox-pane" :key="index">
  100. <el-checkbox style="display:block;" :label="item.id" :value="item.id" name="type" v-model="item.checked" @change="loadThird($event,item, index)">[[empty]]</el-checkbox>
  101. <span @click="tapCheckBox(item, index)" :class="item.color ? 'checkbox-color checkbox-name' : 'checkbox-name'">[[item.name]]</span>
  102. </div>
  103. <!-- </el-checkbox-group> -->
  104. </el-scrollbar>
  105. </el-col>
  106. <el-col :span="8" >
  107. <div class="category-style">三级分类</div>
  108. <el-scrollbar class="scrollbar-style">
  109. <!-- <el-checkbox-group v-model="checkedThirdCate" style="width:100%;text-align: center" style="width:100%" @change="loadThree"> -->
  110. <div v-for="(item, index) in thirdCate" class="checkbox-pane">
  111. <el-checkbox style="display:block;" :label="item.id" :value="item.id" name="type" v-model="item.checked" @change="loadThree($event,item, index)">[[empty]]</el-checkbox>
  112. <span class="checkbox-name">[[item.name]]</span>
  113. </div>
  114. <!-- </el-checkbox-group> -->
  115. </el-scrollbar>
  116. </el-col>
  117. </el-row>
  118. <span slot="footer" class="dialog-footer">
  119. <!-- <el-button @click="dialogVisible = false">取 消</el-button> -->
  120. <el-button type="primary" @click="choose()">确 定</el-button>
  121. </span>
  122. </el-dialog>
  123. </el-form-item>
  124. <el-form-item label="邮费设置">
  125. <el-radio v-model="form.freight_type" :label="1">统一邮费</el-radio>
  126. <el-input v-model.number="form.freight_value" style="width:60%;" :disabled="form.freight_type!=1">
  127. <template slot="append">元</template>
  128. </el-input><br>
  129. <el-radio v-model="form.freight_type" :label="0">运费模板</el-radio>
  130. <el-select v-model="form.template_id" value-key="id" style="width:60%" placeholder="请选择运费模板" :disabled="form.freight_type!=0">
  131. <el-option v-for="item in template_list" :key="item.id" :label="item.dispatch_name" :value="item.id"></el-option>
  132. </el-select>
  133. </el-form-item>
  134. </el-form>
  135. </div>
  136. </div>
  137. <!-- 分页 -->
  138. <div class="vue-page">
  139. <div class="vue-center">
  140. <el-button type="primary" @click="submitForm('form')">保存设置</el-button>
  141. <el-button @click="goBack">返回</el-button>
  142. </div>
  143. </div>
  144. <!--end-->
  145. </div>
  146. </div>
  147. <script>
  148. var vm = new Vue({
  149. el:"#app",
  150. delimiters: ['[[', ']]'],
  151. data() {
  152. // let member_list = JSON.parse('{!! $levels?:'{}' !!}');
  153. let url = JSON.parse('{!! $url !!}');
  154. // let url = {};
  155. let categoryDiscount = JSON.parse('{!! $categoryDispach?:'{}' !!}');
  156. //let categoryDiscount = {};
  157. let classify = JSON.parse('{!! $classify?:'{}' !!}');
  158. console.log(categoryDiscount,456);
  159. let form ={
  160. category_ids:[],
  161. freight_type:1,
  162. freight_value:"",
  163. template_id:1,
  164. ...categoryDiscount,
  165. };
  166. let template_list = JSON.parse('{!! $list?:"{}" !!}');
  167. let classic =[];
  168. let classification = classic.join(",");
  169. let firstCate = JSON.parse('{!! $firstCate?:"{}" !!}');
  170. let secondCate = [];
  171. let thirdCate = [];
  172. let checkedFirstCate = [];
  173. let checkedSecondCate = [];
  174. let checkedThirdCate = [];
  175. let showCate=[];
  176. // var checkNumber = (rule, value, callback) => {
  177. // if (!Number.isInteger(value)) {
  178. // callback(new Error('请输入数字'));
  179. // }
  180. // setTimeout(() => {
  181. // callback();
  182. // }, 1000);
  183. // };
  184. return{
  185. url:url,
  186. form:form,
  187. classic:classic,
  188. template_list:template_list,
  189. // member_list:member_list,
  190. categorys:[],
  191. dialogVisible:true,
  192. dialogTableVisible:false,
  193. loading: false,
  194. submit_loading: false,
  195. firstCate,
  196. secondCate,
  197. thirdCate,
  198. checkedFirstCate,
  199. checkedSecondCate,
  200. checkedThirdCate,
  201. classify,
  202. rules: {
  203. },
  204. keyword:"",//搜索分类
  205. checkedFirstText:[], //获取二级点击文字时的id
  206. categoryArr:[], //保存回显编辑的数据
  207. empty:"",
  208. search_categorys:[],
  209. classification:"",
  210. }
  211. },
  212. mounted() {
  213. if(this.form.category_ids.length) {
  214. // let arr=Object.keys(this.classify)
  215. // if(arr.length!==0){
  216. // this.checkedFirstCate=this.classify[0]
  217. // this.checkedSecondCate=this.classify[1]
  218. // this.checkedThirdCate=this.classify[2]
  219. // this.startLoadThird();
  220. // this.startLoadSecond();
  221. // console.log( this.checkedFirstCate)
  222. // console.log( this.checkedSecondCate)
  223. // console.log( this.checkedThirdCate)
  224. // }
  225. this.categoryArr = this.form.category_ids;
  226. for(let item of this.form.category_ids) {
  227. this.classification += `[ID:${item.id}][分类: ${item.name}],`;
  228. }
  229. }
  230. },
  231. watch: {
  232. 'search_categorys'(newVal,oldVal){
  233. // 二级
  234. for(let cItem of this.secondCate) {
  235. this.$set(cItem,'checked',false)
  236. for(let item of this.search_categorys) {
  237. if(item.id == cItem.id) {
  238. this.$nextTick(() => {
  239. this.$set(cItem,'checked',true)
  240. })
  241. break;
  242. }
  243. }
  244. }
  245. // 三级
  246. for(let cItem of this.thirdCate) {
  247. this.$set(cItem,'checked',false)
  248. for(let item of this.search_categorys) {
  249. if(item.id == cItem.id) {
  250. this.$nextTick(() => {
  251. this.$set(cItem,'checked',true)
  252. })
  253. break;
  254. }
  255. }
  256. }
  257. }
  258. },
  259. methods: {
  260. goBack() {
  261. window.location.href='{!! yzWebFullUrl('discount.batch-dispatch.freight') !!}';
  262. },
  263. loadCategorys(query) {
  264. if (query !== '') {
  265. this.loading = true;
  266. this.$http.get("{!! yzWebUrl('discount.batch-dispatch.select-category', ['keyword' => '']) !!}" + query).then(response => {
  267. this.categorys = response.data.data;
  268. this.data=response.data.data;
  269. this.loading = false;
  270. }, response => {
  271. console.log(response);
  272. });
  273. } else {
  274. this.categorys = [];
  275. }
  276. },
  277. submitForm(formName) {
  278. // if(this.form.discount_method == 1){
  279. // for(let i=0;i<this.member_list.length;i++){
  280. // if(this.form.discount_value[i]<10||this.form.discount_value[i]>0){
  281. // this.$message({message: "折扣数值不能大于10或者小于0",type: 'error'});
  282. // return false;
  283. // }
  284. // }
  285. // }
  286. console.log(this.form,'this.formthis.form');
  287. this.$refs[formName].validate((valid) => {
  288. if (valid) {
  289. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  290. this.$http.post(this.url,{'form_data':this.form}).then(response => {
  291. if (response.data.result) {
  292. this.$message({type: 'success',message: '操作成功!'});
  293. window.location.href='{!! yzWebFullUrl('discount.batch-dispatch.freight') !!}';
  294. } else {
  295. this.$message({message: response.data.msg,type: 'error'});
  296. loading.close();
  297. }
  298. },response => {
  299. loading.close();
  300. });
  301. }else {
  302. console.log('error submit!!');
  303. return false;
  304. }
  305. });
  306. },
  307. goParent() {
  308. window.location.href = `{!! yzWebFullUrl('discount.batch-dispatch.freight') !!}`;
  309. },
  310. choose(){
  311. this.dialogTableVisible = false;
  312. },
  313. visDia() {
  314. if(this.categoryArr.length) {
  315. console.log(1111111);
  316. this.getCategoryData();
  317. return
  318. // this.getCategoryData();
  319. // return
  320. this.categorys = this.categoryArr;
  321. this.search_categorys = this.categoryArr;
  322. }
  323. this.dialogTableVisible = true;
  324. },
  325. // 获取所有的分类数据
  326. getCategoryData() {
  327. this.$http.get("{!! yzWebUrl('discount.batch-dispatch.get-all-cate') !!}").then(({data}) => {
  328. if(data.result) {
  329. console.log(data.data);
  330. this.categorys = data.data;
  331. this.search_categorys = this.categoryArr;
  332. this.dialogTableVisible = true;
  333. }else {
  334. this.$message.error(data.msg);
  335. }
  336. });
  337. },
  338. // getCategoryData() {
  339. // this.$http.get("{!! yzWebUrl('discount.batch-dispatch.get-all-cate') !!}").then(({data}) => {
  340. // if(data.result) {
  341. // this.categorys = data.data;
  342. // this.search_categorys = this.categoryArr;
  343. // this.dialogTableVisible = true;
  344. // }else {
  345. // this.$message.error(data.msg);
  346. // }
  347. // });
  348. // },
  349. // 关闭弹窗回调
  350. closeDialog() {
  351. let newArr = [];
  352. this.classification = "";
  353. for(let item of this.search_categorys) {
  354. this.classification += `[ID:${item.id}][分类: ${item.name}],`
  355. newArr.push(item.id);
  356. }
  357. this.categoryArr = this.search_categorys;
  358. this.form.category_ids = newArr;
  359. },
  360. // startLoadSecond(){
  361. // this.$http.get("{!! yzWebUrl('discount.batch-dispatch.get-child', ['level' => 2]) !!}" + "&cate="+this.checkedFirstCate).then(response => {
  362. // this.secondCate=response.body.data
  363. // }, response => {
  364. // });
  365. // },
  366. // startLoadThird(){
  367. // this.$http.get("{!! yzWebUrl('discount.batch-dispatch.get-child', ['level' => 3]) !!}" + "&cate="+this.checkedSecondCate).then(response => {
  368. // this.thirdCate=response.body.data
  369. // }, response => {
  370. // });
  371. // },
  372. //根据选择的第一级分类请求第二级分类
  373. loadSecond(data){
  374. let val = data[data.length - 1];
  375. this.checkedFirstCate = [val];
  376. this.$http.get("{!! yzWebUrl('discount.batch-dispatch.get-child') !!}"+`&level=2&cate=${val}`).then(({data}) => {
  377. if(data.result) {
  378. this.secondCate = data.data;
  379. this.thirdCate = [];
  380. this.checkedFirstText = [];
  381. // 回显二级分类 ✔
  382. for(let item of this.search_categorys) {
  383. for(let cItem of this.secondCate) {
  384. this.$set(cItem,'checked',false)
  385. if(item.id == cItem.id) {
  386. this.$nextTick(() => {
  387. this.$set(cItem,'checked',true)
  388. })
  389. break;
  390. }
  391. }
  392. }
  393. }else {
  394. this.$message.error(data.msg);
  395. }
  396. });
  397. },
  398. tapCheckBox(row,index) {
  399. // 处理多选搜索
  400. this.$set(this.secondCate[index],'color',this.secondCate[index].color ? false : true);
  401. let secondIndex = this.checkedFirstText.findIndex(item => {
  402. return item == row.id
  403. })
  404. if(secondIndex == -1) {
  405. this.checkedFirstText.push(row.id);
  406. }else {
  407. this.checkedFirstText.splice(secondIndex,1);
  408. }
  409. this.$http.get("{!! yzWebUrl('discount.batch-dispatch.get-child') !!}"+`&level=3&cate=${this.checkedFirstText}`).then(({data}) => {
  410. if(data.result) {
  411. this.thirdCate = data.data;
  412. // 回显三级分类 ✔
  413. for(let item of this.search_categorys) {
  414. for(let cItem of this.thirdCate) {
  415. this.$set(cItem,'checked',false)
  416. if(item.id == cItem.id) {
  417. this.$nextTick(() => {
  418. this.$set(cItem,'checked',true)
  419. })
  420. break;
  421. }
  422. }
  423. }
  424. }else {
  425. this.$message.error(data.msg);
  426. }
  427. });
  428. },
  429. //根据选择的第二级分类请求第三级分类
  430. loadThird($event,row,index){
  431. if(!row.checked) {
  432. // 删除多选框
  433. let secondIndex = this.search_categorys.findIndex(item => {
  434. return item.id == row.id
  435. })
  436. this.search_categorys.splice(secondIndex,1);
  437. return
  438. }
  439. // 选中后添加复选框
  440. this.categorys = [row];
  441. let secondIndex = this.search_categorys.findIndex(item => {
  442. return item.id == row.id
  443. })
  444. if(secondIndex == -1) {
  445. this.search_categorys.push(row);
  446. }
  447. },
  448. loadThree($event,row,index) {
  449. if(!row.checked) {
  450. // 删除多选框
  451. let currentIndex = this.search_categorys.findIndex(item => {
  452. return item.id == row.id
  453. })
  454. this.search_categorys.splice(currentIndex,1);
  455. return
  456. }
  457. // 选中后添加复选框
  458. this.categorys = [row];
  459. let currentIndex = this.search_categorys.findIndex(item => {
  460. return item.id == row.id
  461. })
  462. if(currentIndex == -1) {
  463. this.search_categorys.push(row);
  464. }
  465. }
  466. },
  467. });
  468. </script>
  469. @endsection