index.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. @extends('layouts.base')
  2. @section('title', '禁运地区')
  3. @section('content')
  4. <style>
  5. .panel {
  6. margin-bottom: 10px !important;
  7. padding-left: 20px;
  8. border-radius: 10px;
  9. }
  10. .panel .active a {
  11. background-color: #29ba9c !important;
  12. border-radius: 18px !important;
  13. color: #fff;
  14. }
  15. .panel a {
  16. border: none !important;
  17. background-color: #fff !important;
  18. }
  19. .content {
  20. background: #eff3f6;
  21. padding: 10px !important;
  22. }
  23. .con {
  24. padding-bottom: 20px;
  25. position: relative;
  26. border-radius: 8px;
  27. min-height: 100vh;
  28. background-color: #fff;
  29. }
  30. .con .setting .block {
  31. padding: 10px;
  32. background-color: #fff;
  33. border-radius: 8px;
  34. }
  35. .con .setting .block .title {
  36. font-size: 18px;
  37. margin-bottom: 15px;
  38. display: flex;
  39. align-items: center;
  40. }
  41. .confirm-btn {
  42. width: calc(100% - 266px);
  43. position: fixed;
  44. bottom: 0;
  45. right: 0;
  46. margin-right: 10px;
  47. line-height: 63px;
  48. background-color: #ffffff;
  49. box-shadow: 0px 8px 23px 1px rgba(51, 51, 51, 0.3);
  50. background-color: #fff;
  51. text-align: center;
  52. }
  53. b {
  54. font-size: 14px;
  55. }
  56. </style>
  57. <div id='re_content'>
  58. @include('layouts.newTabs')
  59. <div class="con">
  60. <div class="setting">
  61. <el-form ref="form" :model="form" label-width="15%">
  62. <div class="block">
  63. <div class="title"><span
  64. style="width: 4px;height: 18px;background-color: #29ba9c;margin-right:15px;display:inline-block;"></span><b>基础设置</b>
  65. </div>
  66. <el-form-item label="不配送区域">
  67. <div style="font-size:12px;font-weight:600;line-height:18px;margin-right: 15px">
  68. [[areas]]
  69. </div>
  70. <el-button size="small" @click="openVisible()">选择区域</el-button>
  71. <div style="color:#737373;font-size:12px;">只针对平台自营商品订单,不包括供应商、门店、聚合供应链、供应链中台等</div>
  72. <div style="color:#737373;font-size:12px;">酒店地址若选择在禁运区域内,会给予该区域暂不提供服务</div>
  73. </el-form-item>
  74. <div class="confirm-btn">
  75. <el-button type="primary" @click="submit">提交</el-button>
  76. </div>
  77. </div>
  78. </el-form>
  79. </div>
  80. </div>
  81. <el-dialog title="请选择地区" :visible.sync="centerDialogVisible" center v-if="showVisible"
  82. :before-close="beforeClose">
  83. <el-tree
  84. v-loading="loading"
  85. :props="props"
  86. node-key="id"
  87. :default-checked-keys="area_ids"
  88. :default-expanded-keys="province_ids"
  89. show-checkbox
  90. lazy
  91. @check-change="checkAreas"
  92. ref="addressTree"
  93. :data="treeData"
  94. :load="loadNode"
  95. style="height:500px;overflow:auto"
  96. >
  97. </el-tree>
  98. <span slot="footer" class="dialog-footer">
  99. <el-button @click="beforeClose">取 消</el-button>
  100. <el-button type="primary" @click="saveAreas">确 定</el-button>
  101. </span>
  102. </el-dialog>
  103. </div>
  104. <script>
  105. var vm = new Vue({
  106. el: "#re_content",
  107. delimiters: ['[[', ']]'],
  108. data() {
  109. return {
  110. activeName: 'one',
  111. form: {},
  112. area_ids: [],
  113. province_ids: [],
  114. areas: '',
  115. areaIds: '',
  116. provinceIds: '',
  117. chooseAreas: [],
  118. chooseAreaIds: [],
  119. chooseProvinceIds: [],
  120. centerDialogVisible: false,
  121. showVisible: false,
  122. loading: false,
  123. treeData: [],
  124. props: {
  125. label: 'areaname',
  126. children: 'children',
  127. isLeaf: 'isLeaf'
  128. },
  129. }
  130. },
  131. mounted() {
  132. this.getData()
  133. },
  134. methods: {
  135. getData() {
  136. this.$http.post('{!! yzWebFullUrl('plugin.embargoed-area.admin.embargoed-area.get-info') !!}').then(function (response) {
  137. if (response.data.result) {
  138. if (response.data.data.set) {
  139. this.area_ids = response.data.data.set.area_ids;
  140. this.province_ids = response.data.data.set.province_ids;
  141. this.areas = response.data.data.set.areas;
  142. }
  143. } else {
  144. this.$message({message: response.data.msg, type: 'error'});
  145. }
  146. }, function (response) {
  147. this.$message({message: response.data.msg, type: 'error'});
  148. })
  149. },
  150. submit() {
  151. let loading = this.$loading({
  152. target: document.querySelector(".content"),
  153. background: 'rgba(0, 0, 0, 0)'
  154. });
  155. this.form.area_ids = this.area_ids;
  156. this.form.province_ids = this.province_ids;
  157. this.form.areas = this.areas;
  158. this.$http.post('{!! yzWebFullUrl('plugin.embargoed-area.admin.embargoed-area.edit') !!}', {'express_info': this.form}).then(function (response) {
  159. if (response.data.result) {
  160. this.$message({message: response.data.msg, type: 'success'});
  161. } else {
  162. this.$message({message: response.data.msg, type: 'error'});
  163. }
  164. loading.close();
  165. location.reload();
  166. }, function (response) {
  167. this.$message({message: response.data.msg, type: 'error'});
  168. })
  169. },
  170. openVisible() {
  171. this.centerDialogVisible = true;
  172. this.showVisible = true;
  173. this.area_ids.forEach((item, index) => {
  174. this.area_ids[index] = Number(item)
  175. });
  176. },
  177. loadNode(node, resolve) {
  178. this.loading = true;
  179. if (!node.data.id) {
  180. //省份
  181. node.data.id = 0;
  182. this.$http.get("{!! yzWebUrl('area.list', ['parent_id'=> 0]) !!}").then(response => {
  183. response.data.data.forEach(function (province) {
  184. province.isLeaf = false;
  185. });
  186. resolve(response.data.data);
  187. this.loading = false;
  188. }, response => {
  189. console.log(response);
  190. });
  191. } else {
  192. //城市
  193. this.$http.get("{!! yzWebUrl('area.list', ['parent_id'=> '']) !!}" + node.data.id).then(response => {
  194. //城市没有子节点
  195. response.data.data.forEach(function (city) {
  196. city.isLeaf = true;
  197. })
  198. resolve(response.data.data);
  199. // 载入数据后,刷新已选中
  200. this.loading = false;
  201. }, response => {
  202. console.log(response);
  203. });
  204. }
  205. },
  206. checkAreas(node, checked, children) {
  207. if (node.isLeaf) {
  208. return;
  209. }
  210. if (checked) {
  211. if (!this.province_ids) {
  212. this.province_ids = [];
  213. }
  214. this.province_ids.push(node.id)
  215. }
  216. },
  217. saveAreas() {
  218. let areas = [];
  219. let area_ids = [];
  220. let province_ids = [];
  221. this.$refs.addressTree.getCheckedNodes().forEach(function (node) {
  222. if (node.level == 1) {
  223. province_ids.push(node.id);
  224. } else if (node.level == 2) {
  225. area_ids.push(node.id);
  226. areas.push(node.areaname)
  227. }
  228. });
  229. this.$refs.addressTree.getHalfCheckedNodes().forEach(function (node) {
  230. if (node.level == 1) {
  231. province_ids.push(node.id);
  232. }
  233. });
  234. this.province_ids = province_ids;
  235. this.area_ids = area_ids;
  236. this.areas = areas.join(";");
  237. this.areaIds = area_ids.join(";");
  238. this.provinceIds = province_ids.join(";");
  239. this.centerDialogVisible = false
  240. this.showVisible = false;
  241. },
  242. beforeClose() {
  243. this.centerDialogVisible = false;
  244. this.showVisible = false;
  245. },
  246. handleClose(area) {
  247. this.form.areas.splice(this.form.areas.indexOf(area), 1);
  248. },
  249. },
  250. });
  251. </script>
  252. @endsection