enrolledForm.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <view class="content">
  3. <u-form :model="form" ref="form" label-width="140">
  4. <u-form-item label="订单号" prop="orderNo" required>
  5. <view style="display: flex;">
  6. <u-input v-model="form.orderNo" placeholder="请输入订单号" style="flex: 1;" />
  7. <u-icon name="scan" size="60" style="margin-left: 5px;" @click="scanQRCode()" v-if="payTypeCode == 0"></u-icon>
  8. </view>
  9. </u-form-item>
  10. <u-form-item label="支付方式" prop="payTypeName" required right-icon="arrow-right" @click.native="payTypeShow = true">
  11. <text>{{form.payTypeName}}</text>
  12. </u-form-item>
  13. <u-form-item label="学生照片" prop="imageFileId" required label-position="top">
  14. <u-upload :max-count="1" :action="uploadUrl" :header="uploadHeader" @on-success="uploadSuccess" @on-error="uploadError"
  15. @on-remove="uploadRemove" :file-list="fileList" index="1"></u-upload>
  16. </u-form-item>
  17. <u-form-item label="上传合同" prop="contractFileId" required label-position="top" v-if="payTypeCode == 1">
  18. <u-upload :max-count="1" :action="uploadUrl" :header="uploadHeader" @on-success="uploadSuccess" @on-error="uploadError"
  19. @on-remove="uploadRemove" index="2"></u-upload>
  20. </u-form-item>
  21. <u-form-item label="接收人" prop="coachName" required>
  22. <u-input v-model="form.coachName" placeholder="请输入接收人" disabled />
  23. </u-form-item>
  24. <u-form-item label="家长姓名" prop="parentsName" required>
  25. <u-input v-model="form.parentsName" placeholder="请输入家长姓名" />
  26. </u-form-item>
  27. <u-form-item label="学员姓名" prop="studentName" required>
  28. <u-input v-model="form.studentName" placeholder="请输入学员姓名" />
  29. </u-form-item>
  30. <u-form-item label="学员性别" prop="sex" required right-icon="arrow-right" @click.native="sexShow = true">
  31. <text>{{form.sex}}</text>
  32. </u-form-item>
  33. <u-form-item label="学员年龄" prop="age" required>
  34. <u-input v-model="form.age" type="number" placeholder="请输入学员年龄" />
  35. </u-form-item>
  36. <u-form-item label="学生生日" prop="birthday" required right-icon="arrow-right" @click.native="birthdayShow = true">
  37. <text>{{form.birthday}}</text>
  38. </u-form-item>
  39. <u-form-item label="手机号码" prop="phone" required>
  40. <u-input v-model="form.phone" type="number" placeholder="请输入手机号码" />
  41. </u-form-item>
  42. <u-form-item label="报名班级" prop="className" required right-icon="arrow-right" @click.native="selectClass()">
  43. <text>{{form.className}}</text>
  44. </u-form-item>
  45. <u-form-item label="课时数" prop="courseNumber" required>
  46. <u-input v-model="form.courseNumber" type="number" placeholder="请输入课时数" @blur="setCoursePrice()" />
  47. </u-form-item>
  48. <u-form-item label="课时单价" prop="coursePrice" required>
  49. <u-input v-model="form.coursePrice" type="number" placeholder="请输入课时单价" />
  50. </u-form-item>
  51. <u-form-item label="课时总价" prop="sumPrice" required>
  52. <u-input v-model="form.sumPrice" type="number" placeholder="请输入课时总价" @blur="setCoursePrice()" />
  53. </u-form-item>
  54. <u-form-item label="赠课数量">
  55. <u-input v-model="form.lessonsGiveNumber" type="number" placeholder="请输入赠课数量" />
  56. </u-form-item>
  57. <u-form-item label="赠品" label-position="top"></u-form-item>
  58. <u-form-item :label="item.name" v-for="(item, index1) in giftList" :key="index1">
  59. <u-radio-group v-model="item.value" v-if="item.type == 1">
  60. <u-radio v-for="(site, index2) in item.itemList" :key="index2" :name="site.id">
  61. {{site.name}}
  62. </u-radio>
  63. </u-radio-group>
  64. <u-checkbox-group v-model="item.value" v-else>
  65. <u-checkbox v-model="site.checked" v-for="(site, index2) in item.itemList" :key="index2" :name="site.id">
  66. {{site.name}}
  67. </u-checkbox>
  68. </u-checkbox-group>
  69. </u-form-item>
  70. <u-form-item label="销售员" prop="saleName" required right-icon="arrow-right" @click.native="saleShow = true">
  71. <text>{{form.saleName}}</text>
  72. </u-form-item>
  73. <u-form-item label="谈单人" prop="talkerName" required right-icon="arrow-right" @click.native="talkerShow = true">
  74. <text>{{form.talkerName}}</text>
  75. </u-form-item>
  76. <u-form-item label="备注">
  77. <u-input v-model="form.remark" type="textarea" placeholder="请输入备注" auto-height :height="100" />
  78. </u-form-item>
  79. </u-form>
  80. <u-action-sheet :list="sexList" v-model="sexShow" @click="setSex"></u-action-sheet>
  81. <u-picker v-model="birthdayShow" mode="time" :params="birthdayParams" @confirm="setBirthday"></u-picker>
  82. <u-picker mode="selector" v-model="classShow" :range="classList" range-key="name" @confirm="setClass"></u-picker>
  83. <u-picker mode="selector" v-model="saleShow" :range="saleList" range-key="name" @confirm="setSale"></u-picker>
  84. <u-picker mode="selector" v-model="talkerShow" :range="talkerList" range-key="name" @confirm="setTalker"></u-picker>
  85. <u-picker mode="selector" v-model="payTypeShow" :range="payTypeList" range-key="name" @confirm="setPayType"></u-picker>
  86. <view class="handle-fix-box">
  87. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="submitForm()">提交</u-button>
  88. </view>
  89. <u-top-tips ref="uTips"></u-top-tips>
  90. </view>
  91. </template>
  92. <script>
  93. import {
  94. mapGetters
  95. } from 'vuex'
  96. const NET = require('@/utils/request')
  97. const API = require('@/config/api')
  98. export default {
  99. computed: {
  100. ...mapGetters([
  101. 'customStyle',
  102. ])
  103. },
  104. data() {
  105. return {
  106. uploadUrl: API.uploadFile,
  107. uploadHeader: {
  108. Authorization: uni.getStorageSync('token')
  109. },
  110. payTypeCode: '',
  111. fileList: [],
  112. form: {
  113. imageFileId: '',
  114. contractFileId: '',
  115. coachName: '',
  116. parentsName: '',
  117. studentName: '',
  118. sex: '',
  119. age: '',
  120. birthday: '',
  121. phone: '',
  122. classId: '',
  123. className: '',
  124. courseNumber: '',
  125. coursePrice: '',
  126. sumPrice: '',
  127. orderNo: '',
  128. lessonsGiveNumber: '',
  129. giftId: [],
  130. saleId: '',
  131. saleName: '',
  132. talkerId: '',
  133. talkerName: '',
  134. payTypeId: '',
  135. payTypeName: '',
  136. remark: '',
  137. },
  138. rules: {
  139. coachName: [{
  140. required: true,
  141. message: '请输入接收人',
  142. trigger: 'change'
  143. }],
  144. parentsName: [{
  145. required: true,
  146. message: '请输入家长姓名',
  147. trigger: 'change'
  148. }],
  149. studentName: [{
  150. required: true,
  151. message: '请输入学员姓名',
  152. trigger: 'change'
  153. }],
  154. sex: [{
  155. required: true,
  156. message: '请选择学员性别',
  157. trigger: 'change'
  158. }],
  159. age: [{
  160. required: true,
  161. type: 'number',
  162. message: '请输入学员年龄',
  163. trigger: 'change'
  164. }],
  165. birthday: [{
  166. required: true,
  167. message: '请选择学生生日',
  168. trigger: 'change'
  169. }],
  170. phone: [{
  171. required: true,
  172. message: '请输入手机号码',
  173. trigger: 'change'
  174. },
  175. {
  176. pattern: /^1[0-9]{10}$/g,
  177. transform(value) {
  178. return String(value);
  179. },
  180. message: '请输入正确格式的手机号码'
  181. },
  182. ],
  183. className: [{
  184. required: true,
  185. message: '请选择报名班级',
  186. trigger: 'change'
  187. }],
  188. courseNumber: [{
  189. required: true,
  190. message: '请输入课时数',
  191. trigger: 'change'
  192. }],
  193. coursePrice: [{
  194. required: true,
  195. message: '请输入课时单价',
  196. trigger: 'change'
  197. }],
  198. sumPrice: [{
  199. required: true,
  200. message: '请输入课时总价',
  201. trigger: 'change'
  202. }],
  203. orderNo: [{
  204. required: true,
  205. message: '请输入订单号',
  206. trigger: 'change'
  207. }],
  208. saleName: [{
  209. required: true,
  210. message: '请选择销售员',
  211. trigger: 'change'
  212. }],
  213. talkerName: [{
  214. required: true,
  215. message: '请选择谈单人',
  216. trigger: 'change'
  217. }],
  218. payTypeName: [{
  219. required: true,
  220. message: '请选择支付方式',
  221. trigger: 'change'
  222. }],
  223. },
  224. sexShow: false,
  225. sexList: [{
  226. text: '男'
  227. },
  228. {
  229. text: '女'
  230. }
  231. ],
  232. birthdayShow: false,
  233. birthdayParams: {
  234. year: true,
  235. month: true,
  236. day: true,
  237. hour: false,
  238. minute: false,
  239. second: false
  240. },
  241. classShow: false,
  242. classList: [],
  243. giftList: [],
  244. saleShow: false,
  245. saleList: [],
  246. talkerShow: false,
  247. talkerList: [],
  248. payTypeShow: false,
  249. payTypeList: [],
  250. }
  251. },
  252. onShow() {
  253. if (uni.getStorageSync("defaultClass")) {
  254. this.form.classId = uni.getStorageSync("defaultClass").classId
  255. this.form.className = uni.getStorageSync("defaultClass").className
  256. }
  257. },
  258. onReady() {
  259. this.form.coachName = uni.getStorageSync('userData').nickName
  260. this.$refs.form.setRules(this.rules);
  261. NET.request(API.getClassList, {
  262. page: 1,
  263. size: 1000,
  264. }, 'POST').then(res => {
  265. this.classList = res.data.row
  266. }).catch(error => {
  267. this.$refs.uTips.show({
  268. title: error.message,
  269. type: 'warning',
  270. })
  271. })
  272. NET.request(API.getGiftList, {}, 'POST').then(res => {
  273. res.data.forEach(item => {
  274. if (item == 1) {
  275. item.value = ''
  276. } else {
  277. item.itemList.forEach(site => {
  278. site.checked = false
  279. })
  280. }
  281. })
  282. this.giftList = res.data
  283. }).catch(error => {
  284. this.$refs.uTips.show({
  285. title: error.message,
  286. type: 'warning',
  287. })
  288. })
  289. NET.request(API.getSaleList, {
  290. page: 1,
  291. size: 1000,
  292. }, 'POST').then(res => {
  293. this.saleList = res.data.row
  294. }).catch(error => {
  295. this.$refs.uTips.show({
  296. title: error.message,
  297. type: 'warning',
  298. })
  299. })
  300. NET.request(API.getTalkerList, {
  301. page: 1,
  302. size: 1000,
  303. }, 'POST').then(res => {
  304. this.talkerList = res.data.row
  305. }).catch(error => {
  306. this.$refs.uTips.show({
  307. title: error.message,
  308. type: 'warning',
  309. })
  310. })
  311. NET.request(API.getPayTypeList, {}, 'POST').then(res => {
  312. this.payTypeList = res.data
  313. }).catch(error => {
  314. this.$refs.uTips.show({
  315. title: error.message,
  316. type: 'warning',
  317. })
  318. })
  319. },
  320. methods: {
  321. // 扫码二维码
  322. scanQRCode() {
  323. uni.scanCode({
  324. onlyFromCamera: true,
  325. success: (res) => {
  326. NET.request(API.getQrCodeInfo, {
  327. orderNo: res.result
  328. }, 'POST').then(res => {
  329. this.form.parentsName = res.data.parentsName
  330. this.form.studentName = res.data.studentName
  331. this.form.sex = res.data.sex
  332. this.form.age = res.data.age
  333. this.form.birthday = res.data.birthday
  334. this.form.phone = res.data.phone
  335. if (res.data.payTypeId) {
  336. let payType = this.payTypeList.find(site => site.id == res.data.payTypeId)
  337. this.form.payTypeId = res.data.payTypeId
  338. this.form.payTypeName = payType.id
  339. this.form.payTypeCode = payType.other
  340. }
  341. if (res.data.imageFileId) {
  342. this.form.imageFileId = res.data.imageFileId
  343. this.fileList = [{
  344. url: res.data.imageFileUrl
  345. }]
  346. }
  347. this.form.orderNo = res.data.orderNo
  348. }).catch(error => {
  349. this.$refs.uTips.show({
  350. title: error.message,
  351. type: 'warning',
  352. })
  353. })
  354. }
  355. });
  356. },
  357. // 文件上传成功回调
  358. uploadSuccess(res, index, lists, name) {
  359. if (name == 1) {
  360. this.form.imageFileId = res.data.id
  361. } else if (name == 2) {
  362. this.form.contractFileId = res.data.id
  363. }
  364. this.$refs.uTips.show({
  365. title: '文件上传成功',
  366. type: 'success',
  367. })
  368. return true
  369. },
  370. // 文件上传失败回调
  371. uploadError(res, index, lists, name) {
  372. this.$refs.uTips.show({
  373. title: error.message,
  374. type: 'warning',
  375. })
  376. },
  377. // 移除文件回调
  378. uploadRemove(index, lists, name) {
  379. if (name == 1) {
  380. this.form.imageFileId = ''
  381. } else if (name == 2) {
  382. this.form.contractFileId = ''
  383. }
  384. },
  385. // 设置性别
  386. setSex(index) {
  387. this.form.sex = this.sexList[index].text
  388. },
  389. // 设置生日
  390. setBirthday(object) {
  391. this.form.birthday = object.year + '-' + object.month + '-' + object.day
  392. },
  393. // 跳转班级列表
  394. selectClass() {
  395. uni.navigateTo({
  396. url: '/pagesEnroll/classList'
  397. });
  398. },
  399. // 设置报名班级
  400. setClass(object) {
  401. this.form.classId = this.classList[object[0]].id
  402. this.form.className = this.classList[object[0]].name
  403. },
  404. // 设置销售员
  405. setSale(object) {
  406. this.form.saleId = this.saleList[object[0]].id
  407. this.form.saleName = this.saleList[object[0]].name
  408. },
  409. // 设置谈单人
  410. setTalker(object) {
  411. this.form.talkerId = this.talkerList[object[0]].id
  412. this.form.talkerName = this.talkerList[object[0]].name
  413. },
  414. // 设置支付方式
  415. setPayType(object) {
  416. this.form.payTypeId = this.payTypeList[object[0]].id
  417. this.form.payTypeName = this.payTypeList[object[0]].name
  418. this.payTypeCode = this.payTypeList[object[0]].other
  419. },
  420. // 设置总价
  421. setCoursePrice() {
  422. if (this.form.courseNumber && this.form.sumPrice) {
  423. this.form.coursePrice = (this.form.sumPrice / this.form.courseNumber).toFixed(2)
  424. }
  425. },
  426. // 提交表单
  427. submitForm() {
  428. this.$refs.form.validate(valid => {
  429. if (valid) {
  430. let giftId = []
  431. this.giftList.forEach(item => {
  432. if (item.type == 1 && item.value) {
  433. giftId.push(item.value)
  434. } else if (item.type == 0) {
  435. giftId = giftId.concat(item.itemList.filter(site => site.checked).map(site => {
  436. return site.id
  437. }))
  438. }
  439. })
  440. NET.request(API.submitEnrolledForm, {
  441. ...this.form,
  442. giftId: giftId
  443. }, 'POST').then(res => {
  444. this.$refs.uTips.show({
  445. title: '提交成功',
  446. type: 'success',
  447. })
  448. setTimeout(() => {
  449. uni.navigateBack()
  450. }, 1000)
  451. }).catch(error => {
  452. this.$refs.uTips.show({
  453. title: error.message,
  454. type: 'warning',
  455. })
  456. })
  457. }
  458. });
  459. },
  460. },
  461. }
  462. </script>
  463. <style>
  464. page {
  465. width: 100%;
  466. height: 100%;
  467. position: relative;
  468. }
  469. </style>
  470. <style lang="scss" scoped>
  471. @import "@/static/css/themes.scss";
  472. .content {
  473. width: 100%;
  474. float: left;
  475. padding: 0 15px 60px 15px;
  476. box-sizing: border-box;
  477. }
  478. </style>