basic.blade.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. @extends('layouts.base')
  2. @section('title', '基础设置')
  3. @section('content')
  4. <link rel="stylesheet" href="{{resource_get('plugins/electricity-bill-pro/views/backend/index.css')}}">
  5. <style>
  6. .panel {
  7. margin-bottom: 10px !important;
  8. padding-left: 20px;
  9. border-radius: 10px;
  10. }
  11. .panel .active a {
  12. background-color: #29ba9c !important;
  13. border-radius: 18px !important;
  14. color: #fff;
  15. }
  16. .panel a {
  17. border: none !important;
  18. background-color: #fff !important;
  19. }
  20. .content {
  21. background: #eff3f6;
  22. padding: 10px !important;
  23. }
  24. .con {
  25. padding-bottom: 20px;
  26. position: relative;
  27. border-radius: 8px;
  28. min-height: 100vh;
  29. background-color: #fff;
  30. }
  31. .con .setting .block {
  32. padding: 10px;
  33. background-color: #fff;
  34. border-radius: 8px;
  35. }
  36. .con .setting .block .title {
  37. font-size: 18px;
  38. margin-bottom: 15px;
  39. display: flex;
  40. align-items: center;
  41. }
  42. .confirm-btn {
  43. width: calc(100% - 266px);
  44. position: fixed;
  45. bottom: 0;
  46. right: 0;
  47. margin-right: 10px;
  48. line-height: 63px;
  49. background-color: #ffffff;
  50. box-shadow: 0px 8px 23px 1px rgba(51, 51, 51, 0.3);
  51. background-color: #fff;
  52. text-align: center;
  53. }
  54. b {
  55. font-size: 14px;
  56. }
  57. .setting .block .channel-set .channel-set{
  58. font-size: 16px;
  59. }
  60. .setting .block .channel-set .el-radio__inner {
  61. width: 18px;
  62. height: 18px;
  63. }
  64. </style>
  65. <div id='app'>
  66. <div class="con">
  67. <div class="setting">
  68. <el-form ref="form" :model="form" label-width="15%">
  69. <div class="block">
  70. <div class="title"><span
  71. style="width: 4px;height: 18px;background-color: #29ba9c;margin-right:15px;display:inline-block;"></span><b>基础设置</b>
  72. </div>
  73. <el-form-item label="电费充值">
  74. <template>
  75. <el-switch v-model="form.is_open" :active-value="1" :inactive-value="0">
  76. </el-switch>
  77. </template>
  78. </el-form-item>
  79. <!-- <el-form-item label="通道设置">
  80. <template>
  81. <el-tabs v-model="activeName" type="card" v-if="!(form.channel_list instanceof Array)">
  82. <el-tab-pane v-for="(item,index) in form.channel_list" :label="item.name" :name="index">
  83. <el-form label-width="80px">
  84. <el-form-item label="是否启用">
  85. <template>
  86. <el-switch v-model="item.is_open" :active-value="1" :inactive-value="0">
  87. </el-switch>
  88. </template>
  89. </el-form-item>
  90. </el-form>
  91. </el-tab-pane>
  92. </el-tabs>
  93. <el-tabs v-model="activeName" v-else>
  94. <el-tab-pane label="无" name="aggregation-cps">
  95. <el-form label-width="80px">
  96. 无通道
  97. </el-form>
  98. </el-tab-pane>
  99. </el-tabs>
  100. </template>
  101. </el-form-item> -->
  102. <el-form-item label="通道设置" class="channel-set" v-if="form.channel_list">
  103. <el-radio-group v-model="channel_type" @change="changeChannel">
  104. <el-radio v-for="(item,index) in form.channel_list" :label="index">[[item.name]]</el-radio>
  105. </el-radio-group>
  106. </el-form-item>
  107. <el-form-item label="充值失败不退款">
  108. <template>
  109. <el-switch
  110. v-model="form.is_no_refund"
  111. :active-value="1"
  112. :inactive-value="0"
  113. >
  114. </el-switch>
  115. </template>
  116. </el-form-item>
  117. <el-form-item label="默认下单地址">
  118. <template>
  119. <el-switch
  120. v-model="form.is_default_address"
  121. :active-value="1"
  122. :inactive-value="0"
  123. >
  124. </el-switch>
  125. </template>
  126. </el-form-item>
  127. <el-form-item label="">
  128. <el-input v-model="form.username" placeholder="默认下单用户姓名" style="width:70%;"></el-input>
  129. </el-form-item>
  130. <el-form-item label="">
  131. <el-input v-model="form.mobile" placeholder="默认下单用户手机号" style="width:70%;"></el-input>
  132. </el-form-item>
  133. <el-form-item label="">
  134. <el-select v-model="form.province_id" placeholder="省" clearable @change="changeProvince"
  135. style="width:15%">
  136. <el-option v-for="item in province_list" :key="item.id" :label="item.areaname"
  137. :value="item.id"></el-option>
  138. </el-select>
  139. <el-select v-model="form.city_id" placeholder="市" clearable @change="changeCity"
  140. style="width:15%">
  141. <el-option v-for="item in city_list" :key="item.id" :label="item.areaname"
  142. :value="item.id"></el-option>
  143. </el-select>
  144. <el-select v-model="form.district_id" placeholder="区" clearable @change="changeDistrict"
  145. style="width:15%">
  146. <el-option v-for="item in district_list" :key="item.id" :label="item.areaname"
  147. :value="item.id"></el-option>
  148. </el-select>
  149. <el-select v-model="form.street_id" placeholder="街道" clearable style="width:15%">
  150. <el-option v-for="item in street_list" :key="item.id" :label="item.areaname"
  151. :value="item.id"></el-option>
  152. </el-select>
  153. </el-form-item>
  154. <el-form-item label="">
  155. <el-input v-model="form.address" placeholder="详细地址" style="width:70%;"></el-input>
  156. </el-form-item>
  157. <el-form-item label="限制区域">
  158. <template>
  159. <el-button @click="dialogFormVisible=true">选择省份</el-button>
  160. <div>
  161. <el-tag
  162. v-for="(tag, index) in authList" :key="index"
  163. closable @close="deleteAuth(index)"
  164. style="margin: 0 10px 10px 0"
  165. >
  166. [[tag]]
  167. </el-tag>
  168. </div>
  169. </template>
  170. </el-form-item>
  171. <div class="confirm-btn">
  172. <el-button type="primary" @click="submitForm('form')">提交</el-button>
  173. </div>
  174. </div>
  175. </el-form>
  176. <el-dialog title="选择地区" :visible.sync="dialogFormVisible">
  177. <el-checkbox-group v-model="authList">
  178. <el-checkbox v-for="item in province_list" :key="item.id" :label="item.areaname"></el-checkbox>
  179. </el-checkbox-group>
  180. <div slot="footer" class="dialog-footer">
  181. <el-button @click="dialogFormVisible = false">取 消</el-button>
  182. <el-button type="primary" @click="confirmDialog">确 定</el-button>
  183. </div>
  184. </el-dialog>
  185. </div>
  186. </div>
  187. </div>
  188. <script>
  189. var app = new Vue({
  190. el: "#app",
  191. delimiters: ['[[', ']]'],
  192. name: 'test',
  193. data() {
  194. return {
  195. form: {
  196. is_open: 0,
  197. province_id: '',
  198. city_id: '',
  199. district_id: '',
  200. street_id: '',
  201. channel_list: {},
  202. limit_area: []
  203. },
  204. submit_url: '',
  205. channel_type: '',
  206. showVisible: false,
  207. loading: false,
  208. province_list: [],
  209. city_list: [],
  210. district_list: [],
  211. street_list: [],
  212. rules: {},
  213. activeName:'aggregation-cps',
  214. dialogFormVisible: false,
  215. authList: [],
  216. }
  217. },
  218. created() {
  219. },
  220. mounted() {
  221. this.initProvince();
  222. this.getData();
  223. },
  224. methods: {
  225. getData() {
  226. let loading = this.$loading({
  227. target: document.querySelector(".content"),
  228. background: 'rgba(0, 0, 0, 0)'
  229. });
  230. this.$http.post('{!! yzWebFullUrl('plugin.electricity-bill-pro.backend.set.basic-info') !!}').then(function (response) {
  231. if (response.data.result) {
  232. this.form = response.data.data.set;
  233. this.form.province_id = this.form.province_id ? this.form.province_id : '';
  234. this.form.city_id = this.form.city_id ? this.form.city_id : '';
  235. this.form.district_id = this.form.district_id ? this.form.district_id : '';
  236. this.form.street_id = this.form.street_id ? this.form.street_id : '';
  237. this.authList = this.form.limit_area ? this.form.limit_area : [];
  238. if (this.form.province_id > 0) {
  239. this.initCity(this.form.province_id);
  240. }
  241. if (this.form.city_id > 0) {
  242. this.initDistrict(this.form.city_id);
  243. }
  244. if (this.form.district_id > 0) {
  245. this.initStreet(this.form.district_id);
  246. }
  247. if (this.form.channel_list) {
  248. let channelList = this.form.channel_list;
  249. let check = Object.keys(channelList).find(item => channelList[item].is_open == 1);
  250. this.channel_type = check;
  251. }
  252. loading.close();
  253. } else {
  254. this.$message({
  255. message: response.data.msg,
  256. type: 'error'
  257. });
  258. }
  259. loading.close();
  260. }, function (response) {
  261. this.$message({
  262. message: response.data.msg,
  263. type: 'error'
  264. });
  265. loading.close();
  266. });
  267. },
  268. submitForm(formName) {
  269. let that = this;
  270. let json = this.form;
  271. json.limit_area = this.authList;
  272. this.$refs[formName].validate((valid) => {
  273. if (valid) {
  274. let loading = this.$loading({
  275. target: document.querySelector(".content"),
  276. background: 'rgba(0, 0, 0, 0)'
  277. });
  278. this.$http.post('{!! yzWebFullUrl('plugin.electricity-bill-pro.backend.set.basic-save') !!}', {set: json}).then(response => {
  279. if (response.data.result) {
  280. this.$message({message: response.data.msg, type: 'success'});
  281. } else {
  282. this.$message({message: response.data.msg, type: 'error'});
  283. }
  284. loading.close();
  285. }, response => {
  286. loading.close();
  287. });
  288. } else {
  289. console.log('error submit!!');
  290. return false;
  291. }
  292. });
  293. },
  294. goBack() {
  295. history.go(-1)
  296. },
  297. changeChannel(checkName) {
  298. let channelList = this.form.channel_list
  299. Object.keys(channelList).forEach(item => {
  300. channelList[item].is_open = (item == checkName) ? 1 : 0;
  301. });
  302. },
  303. initProvince(val) {
  304. this.areaLoading = true;
  305. this.$http.get("{!! yzWebUrl('area.list.init', ['area_ids'=>'']) !!}" + val).then(response => {
  306. this.province_list = response.data.data;
  307. this.areaLoading = false;
  308. }, response => {
  309. this.areaLoading = false;
  310. });
  311. },
  312. initCity(val) {
  313. console.log(val);
  314. this.areaLoading = true;
  315. this.$http.get("{!! yzWebUrl('area.list', ['parent_id'=>'']) !!}" + val).then(response => {
  316. this.city_list = response.data.data;
  317. this.areaLoading = false;
  318. }, response => {
  319. this.areaLoading = false;
  320. });
  321. },
  322. initDistrict(val) {
  323. console.log(val);
  324. this.areaLoading = true;
  325. this.$http.get("{!! yzWebUrl('area.list', ['parent_id'=>'']) !!}" + val).then(response => {
  326. this.district_list = response.data.data;
  327. this.areaLoading = false;
  328. }, response => {
  329. this.areaLoading = false;
  330. });
  331. },
  332. initStreet(val) {
  333. console.log(val);
  334. this.areaLoading = true;
  335. this.$http.get("{!! yzWebUrl('area.list', ['parent_id'=>'']) !!}" + val).then(response => {
  336. this.street_list = response.data.data;
  337. this.areaLoading = false;
  338. }, response => {
  339. this.areaLoading = false;
  340. });
  341. },
  342. changeProvince(val) {
  343. this.city_list = [];
  344. this.district_list = [];
  345. this.street_list = [];
  346. this.form.city_id = "";
  347. this.form.district_id = "";
  348. this.form.street_id = "";
  349. this.areaLoading = true;
  350. let url = "<?php echo yzWebUrl('area.list', ['parent_id' => '']); ?>" + val;
  351. this.$http.get(url).then(response => {
  352. if (response.data.data.length) {
  353. this.city_list = response.data.data;
  354. } else {
  355. this.city_list = null;
  356. }
  357. this.areaLoading = false;
  358. }, response => {
  359. this.areaLoading = false;
  360. });
  361. },
  362. // 市改变
  363. changeCity(val) {
  364. this.district_list = [];
  365. this.street_list = [];
  366. this.form.district_id = "";
  367. this.form.street_id = "";
  368. this.areaLoading = true;
  369. let url = "<?php echo yzWebUrl('area.list', ['parent_id' => '']); ?>" + val;
  370. this.$http.get(url).then(response => {
  371. if (response.data.data.length) {
  372. this.district_list = response.data.data;
  373. } else {
  374. this.district_list = null;
  375. }
  376. this.areaLoading = false;
  377. }, response => {
  378. this.areaLoading = false;
  379. });
  380. },
  381. // 区改变
  382. changeDistrict(val) {
  383. console.log(val)
  384. this.street_list = [];
  385. this.form.street_id = "";
  386. this.areaLoading = true;
  387. let url = "<?php echo yzWebUrl('area.list', ['parent_id' => '']); ?>" + val;
  388. this.$http.get(url).then(response => {
  389. if (response.data.data.length) {
  390. this.street_list = response.data.data;
  391. } else {
  392. this.street_list = null;
  393. }
  394. this.areaLoading = false;
  395. }, response => {
  396. this.areaLoading = false;
  397. });
  398. },
  399. confirmDialog () {
  400. this.dialogFormVisible = false;
  401. },
  402. deleteAuth (index) {
  403. this.authList.splice(index, 1);
  404. }
  405. },
  406. })
  407. </script>
  408. @endsection