index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <div class="common-container">
  3. <TitleBar></TitleBar>
  4. <div>
  5. <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
  6. <el-tab-pane label="当前设置" name="1"></el-tab-pane>
  7. <el-tab-pane label="待审核" name="2"></el-tab-pane>
  8. <el-tab-pane label="待提交" name="3"></el-tab-pane>
  9. </el-tabs>
  10. </div>
  11. <div class="content-box">
  12. <el-form :model="formData" :rules="rules" ref="formData" label-width="180px">
  13. <el-form-item label="平台选择专家默认收费:" prop="appointExpertPrice">
  14. <el-input
  15. v-model="formData.appointExpertPrice"
  16. :disabled="!show"
  17. placeholder="请输入"
  18. maxlength="10"
  19. ></el-input>
  20. </el-form-item>
  21. <el-form-item label="附近人范围:" prop="nearPeopleArea">
  22. <el-input v-model="formData.nearPeopleArea" :disabled="!show" placeholder="请输入" maxlength="10">
  23. <template slot="append">公里</template>
  24. </el-input>
  25. </el-form-item>
  26. <el-form-item label="税率:" prop="defaultTax">
  27. <el-input v-model="formData.defaultTax" :disabled="!show" placeholder="请输入" maxlength="10">
  28. <template slot="append">%</template>
  29. </el-input>
  30. </el-form-item>
  31. <el-form-item label="单次提现上限金额:" prop="withdrawFee">
  32. <el-input v-model="formData.withdrawFee" :disabled="!show" placeholder="请输入" maxlength="10">
  33. </el-input>
  34. </el-form-item>
  35. <el-form-item label="每月提现次数:" prop="withdrawNum">
  36. <el-input v-model="formData.withdrawNum" :disabled="!show" placeholder="请输入" maxlength="10">
  37. </el-input>
  38. </el-form-item>
  39. <el-form-item label="专家出诊打卡范围:" prop="clockInArea">
  40. <el-input v-model="formData.clockInArea" :disabled="!show" placeholder="请输入" maxlength="10">
  41. <template slot="append">米</template>
  42. </el-input>
  43. </el-form-item>
  44. <el-form-item label="间隔时间:" prop="intervalTime">
  45. <el-input v-model="formData.intervalTime" :disabled="!show" placeholder="请输入" maxlength="10">
  46. <template slot="append">分钟</template>
  47. </el-input>
  48. </el-form-item>
  49. <el-form-item label="经纬度推送开关:" prop="isPush">
  50. <el-switch
  51. v-model="formData.isPush"
  52. active-text="开"
  53. inactive-text="关"
  54. :active-value="1"
  55. :inactive-value="0"
  56. :disabled="!show"
  57. ></el-switch>
  58. </el-form-item>
  59. </el-form>
  60. <div class="btn">
  61. <el-button type="primary" round v-if="activeName == '3'" @click="reset">重置</el-button>
  62. <el-button type="primary" round v-if="activeName == '3'" @click="submit('save')">保存</el-button>
  63. <el-button
  64. type="primary"
  65. :disabled="btndisabled"
  66. round
  67. v-if="activeName == '3'"
  68. @click="submit('submit')"
  69. >提交</el-button>
  70. </div>
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import TitleBar from '@/apps/mobile/components/common/TitleBar';
  76. import {
  77. addData,
  78. addDataSave,
  79. removeData,
  80. editData,
  81. examine,
  82. queryNew,
  83. queryHistory,
  84. queryCommit,
  85. queryStay,
  86. submitData,
  87. } from '@/apps/mobile/api/operation/other-settings/index';
  88. import { validWithoutZero, validPositiveInteger } from '@/apps/mobile/utils/validate';
  89. export default {
  90. components: {
  91. TitleBar,
  92. },
  93. data() {
  94. var checkPrice = (rule, value, callback) => {
  95. if (value && !validWithoutZero(value)) {
  96. callback(new Error('格式不正确'));
  97. } else {
  98. callback();
  99. }
  100. };
  101. // 正整数校验
  102. var checkNum = (rule, value, callback) => {
  103. if (value && !validPositiveInteger(value)) {
  104. callback(new Error('格式不正确'));
  105. } else {
  106. callback();
  107. }
  108. };
  109. return {
  110. input: '',
  111. rules: {
  112. appointExpertPrice: [
  113. { required: true, message: '请输入平台选择专家最低费用' },
  114. { validator: checkPrice, message: '请输入正确的费用', trigger: 'blur' },
  115. ],
  116. nearPeopleArea: [
  117. { required: true, message: '请输入附近人范围数' },
  118. { validator: checkPrice, message: '请输入正确的范围数', trigger: 'blur' },
  119. ],
  120. defaultTax: [
  121. { required: true, message: '请输入税率' },
  122. { validator: checkPrice, message: '请输入正确的税率', trigger: 'blur' },
  123. ],
  124. withdrawFee: [
  125. { required: true, message: '请输入单次提现上限金额' },
  126. { validator: checkPrice, message: '请输入正确的单次提现上限金额', trigger: 'blur' },
  127. ],
  128. withdrawNum: [
  129. { required: true, message: '请输入每月提现次数' },
  130. { validator: checkNum, message: '请输入正整数', trigger: 'blur' },
  131. ],
  132. clockInArea: [
  133. { required: true, message: '请输入打卡范围' },
  134. { validator: checkNum, message: '请输入正整数', trigger: 'blur' },
  135. ],
  136. intervalTime: [
  137. { required: true, message: '请输入间隔时间' },
  138. { validator: checkPrice, message: '请输入正确的分钟数', trigger: 'blur' },
  139. ],
  140. is_push: [
  141. { required: false }
  142. ],
  143. },
  144. formData: {},
  145. activeName: '1',
  146. show: 0,
  147. btndisabled: false,
  148. id: null, //待提交数据ID
  149. auditId: null, //待审核id
  150. editobj: {}, // 储存待提交的数据
  151. theSame: true, // 待提交的数据是否改变 false改变 true未变
  152. };
  153. },
  154. methods: {
  155. /**
  156. * 提交或保存操作
  157. * @param {String} type 操作类型 'save' 保存操作 'sunmit' 提交操作
  158. */
  159. submit(type) {
  160. this.$refs.formData.validate(valid => {
  161. if (valid) {
  162. let obj = this.formData;
  163. let submitObj = {
  164. appointExpertPrice: obj.appointExpertPrice,
  165. nearPeopleArea: obj.nearPeopleArea,
  166. defaultTax: obj.defaultTax,
  167. withdrawFee: obj.withdrawFee,
  168. withdrawNum: obj.withdrawNum,
  169. clockInArea: obj.clockInArea,
  170. intervalTime: obj.intervalTime,
  171. isPush: obj.isPush,
  172. };
  173. if (type === 'save') {
  174. if (this.id && this.theSame) return this.$message.warning('未做修改!');
  175. // 如果有改变,修改当前保存的数据,需要提交id
  176. if (this.id && !this.theSame) {
  177. submitObj.id = this.id;
  178. }
  179. addDataSave(submitObj)
  180. .then(res => {
  181. console.log(res);
  182. if (res.statusCode === '1') {
  183. this.$message.success(res.message);
  184. this.id = res.data;
  185. } else {
  186. this.$message.warning(res.message);
  187. }
  188. this.btndisabled = false;
  189. this.queryCommitData();
  190. })
  191. .catch(() => {
  192. this.btndisabled = false;
  193. });
  194. } else {
  195. // 提交操作
  196. if (this.id) {
  197. // 有待提交数据,提交
  198. submitData(this.id)
  199. .then(res => {
  200. console.log(res);
  201. if (res.statusCode === '1') {
  202. this.$message.success(res.message);
  203. this.id = null;
  204. this.btndisabled = false;
  205. this.$refs['formData'].resetFields();
  206. this.formData = {};
  207. } else {
  208. this.$message.error(res.message);
  209. }
  210. })
  211. .catch(() => {
  212. this.btndisabled = false;
  213. });
  214. } else {
  215. // 没有待提交数据,新增
  216. addData(submitObj)
  217. .then(res => {
  218. if (res.statusCode === '1') {
  219. this.$message.success(res.message);
  220. this.btndisabled = false;
  221. this.$refs['formData'].resetFields();
  222. this.formData = {};
  223. } else {
  224. this.$message.warning(res.message);
  225. }
  226. })
  227. .catch(() => {
  228. this.btndisabled = false;
  229. });
  230. }
  231. }
  232. } else {
  233. return false;
  234. }
  235. });
  236. },
  237. reset() {
  238. this.formData = {};
  239. this.$refs.formData.resetFields();
  240. },
  241. // 进入审批页面调用
  242. showChange() {
  243. this.show = 0;
  244. this.queryNewData();
  245. },
  246. // 点击标签页
  247. handleClick(tab) {
  248. console.log(tab, 'activeName');
  249. if (tab.name === '1') {
  250. // 查询当前设置
  251. this.queryNewData();
  252. }
  253. if (tab.name === '2') {
  254. // 查询待审核的
  255. this.queryStayData();
  256. }
  257. if (tab.name === '3') {
  258. // 查询待提交的
  259. this.queryCommitData();
  260. }
  261. },
  262. // 查询待审核
  263. queryStayData() {
  264. queryStay()
  265. .then(res => {
  266. console.log(res);
  267. if (res.data && res.data.length > 0) {
  268. this.formData = res.data.pop();
  269. this.auditId = this.formData.id;
  270. } else {
  271. this.auditId = null;
  272. this.reset();
  273. }
  274. })
  275. .catch(err => err);
  276. },
  277. // 查询最新版本
  278. queryNewData() {
  279. if (this.activeName === '1') {
  280. queryNew()
  281. .then(res => {
  282. console.log(res, '最新');
  283. if (res.data.id) {
  284. this.formData = res.data;
  285. } else {
  286. this.reset();
  287. }
  288. })
  289. .catch(err => err);
  290. }
  291. },
  292. // 查询待提交的数据
  293. queryCommitData() {
  294. queryCommit()
  295. .then(res => {
  296. console.log(res);
  297. if (res.data && res.data.length > 0) {
  298. this.formData = res.data.pop();
  299. this.editobj = Object.assign({
  300. ...this.formData,
  301. });
  302. this.id = this.formData.id;
  303. } else {
  304. this.id = null;
  305. this.reset();
  306. }
  307. })
  308. .catch(err => err);
  309. },
  310. // 审批
  311. approval(data) {
  312. examine(data).then(res => {
  313. if (res.statusCode === '1') {
  314. this.$message.success(res.message);
  315. this.auditId = null;
  316. this.queryStayData();
  317. } else {
  318. this.$message.warning(res.message);
  319. }
  320. });
  321. }
  322. },
  323. created() {
  324. // 如果是设置页面,查询待提交的数据
  325. this.$nextTick(() => {
  326. this.queryNewData();
  327. });
  328. },
  329. watch: {
  330. // 判断用户是都修改了数据
  331. formData: {
  332. handler(newVal) {
  333. if (JSON.stringify(newVal) !== JSON.stringify(this.editobj)) {
  334. this.theSame = false;
  335. } else {
  336. this.theSame = true;
  337. }
  338. },
  339. deep: true,
  340. },
  341. activeName(val){
  342. if(val == 3){
  343. this.show = 1;
  344. }
  345. else{
  346. this.show = 0;
  347. }
  348. }
  349. },
  350. };
  351. </script>
  352. <style scoped>
  353. .TableSelectMain .el-date-editor.el-input.el-input--prefix.el-input--suffix.el-date-editor--date {
  354. width: 95%;
  355. }
  356. .el-input {
  357. width: 200px;
  358. }
  359. ::v-deep .el-input-group__append {
  360. background-color: #fff;
  361. border: none;
  362. color: #000;
  363. }
  364. ::v-deep .el-input__inner {
  365. width: auto;
  366. }
  367. .content-box {
  368. margin-left: 100px;
  369. margin-top: 20px;
  370. }
  371. .btn {
  372. margin-left: 250px;
  373. margin-top: 100px;
  374. }
  375. </style>