studentOrder.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <div class='studentOrder'>
  3. <div class="headWrap">
  4. <div class="left">
  5. <div class="headItem">
  6. <p>账户余额:<span>{{ dataInfo.balance }}</span></p>
  7. <el-button type="text" v-permission="'userCashAccount/transferCourseBalanceToBalance'" @click="rechargeVisible=true">充值</el-button>
  8. </div>
  9. <div class="headItem">
  10. <p v-if="amountStatus">课程余额:<span>{{ dataInfo.courseBalance }}</span></p>
  11. <p v-else>课程余额:<span>
  12. <el-input style="width: 130px;"
  13. v-model.trim="dataInfo.courseBalance"
  14. placeholder="课程余额"></el-input>
  15. </span></p>
  16. <el-button v-if="amountStatus"
  17. v-permission="'userCashAccount/updateCourseBalance'"
  18. @click="amountStatus = false"
  19. type="text">修改</el-button>
  20. <el-button style="top:0;"
  21. @click="onUpdateCourse"
  22. v-else
  23. type="text">保存</el-button>
  24. </div>
  25. <div class="headItem">
  26. <p>银行卡:<span>{{ dataInfo.cardNo }}</span></p>
  27. </div>
  28. <!-- <div class="headItem">
  29. <p>支付宝:<span>{{ dataInfo.zfb }}</span></p>
  30. </div>
  31. <div class="headItem">
  32. <p>微信:<span>{{ dataInfo.wxBalance }}</span></p>
  33. </div> -->
  34. </div>
  35. </div>
  36. <!-- 搜索类型 -->
  37. <el-form :inline="true"
  38. class="searchForm"
  39. v-model.trim="searchForm">
  40. <el-form-item>
  41. <el-date-picker style="width: 400px;"
  42. v-model.trim="orderDate"
  43. type="daterange"
  44. value-format="yyyy-MM-dd"
  45. @change="searchCourseDate"
  46. range-separator="至"
  47. start-placeholder="订单开始日期"
  48. end-placeholder="订单结束日期">
  49. </el-date-picker>
  50. </el-form-item>
  51. <el-form-item>
  52. <el-select v-model.trim="searchForm.paymentType"
  53. filterable
  54. clearable
  55. @clear="onClear('paymentType')"
  56. placeholder="交易类型">
  57. <el-option v-for="(item, index) in orderStatus"
  58. :key="index"
  59. :label="item.label"
  60. :value="item.value"></el-option>
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item>
  64. <el-input type="text"
  65. @keyup.enter.native='search'
  66. v-model.trim="searchForm.remark"
  67. placeholder="订单说明"></el-input>
  68. </el-form-item>
  69. <el-form-item>
  70. <el-button @click="search"
  71. type="danger">搜索</el-button>
  72. <el-button @click="onReSet"
  73. type="primary">重置</el-button>
  74. </el-form-item>
  75. </el-form>
  76. <div class="tableWrap">
  77. <el-table :data="tableList"
  78. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  79. <el-table-column label="订单日期"
  80. prop="createTime"
  81. align='center'
  82. width="150px">
  83. <template slot-scope="scope">
  84. {{ scope.row.createTime | dateForMinFormat }}
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="交易类型"
  88. align='center'
  89. width="180px">
  90. <template slot-scope="scope">
  91. {{ scope.row.type | orderType }}
  92. </template>
  93. </el-table-column>
  94. <el-table-column width="180px"
  95. align='center'
  96. label="应付金额"
  97. prop="expectAmount">
  98. </el-table-column>
  99. <el-table-column width="180px"
  100. align='center'
  101. label="余额支付"
  102. prop="balancePaymentAmount">
  103. </el-table-column>
  104. <el-table-column width="180px"
  105. align='center'
  106. label="实际金额"
  107. prop="actualAmount">
  108. </el-table-column>
  109. <el-table-column width="180px"
  110. align='center'
  111. label="订单状态"
  112. prop="status">
  113. <template slot-scope="scope">
  114. <div >
  115. {{scope.row.status | payStatus}}
  116. </div>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="订单说明"
  120. align='center'
  121. prop="memo">
  122. </el-table-column>
  123. </el-table>
  124. <pagination :total="pageInfo.total"
  125. :page.sync="pageInfo.page"
  126. :limit.sync="pageInfo.limit"
  127. :page-sizes="pageInfo.page_size"
  128. @pagination="getList" />
  129. </div>
  130. <!-- 充值弹窗 -->
  131. <el-dialog
  132. title="课程余额转账户余额"
  133. width="400px"
  134. :visible.sync="rechargeVisible"
  135. >
  136. <el-form
  137. :model="rechargeForm"
  138. ref="rechargeForm"
  139. label-position="right"
  140. label-width="80px;"
  141. :inline="true"
  142. >
  143. <el-form-item label="课程余额" >
  144. ¥{{ dataInfo.courseBalance}}
  145. </el-form-item>
  146. <el-form-item label="本次充值" prop="money">
  147. <el-input type="number" @mousewheel.native.prevent v-model.trim="rechargeForm.money"></el-input>
  148. </el-form-item>
  149. </el-form>
  150. <div slot="footer" class="dialog-footer">
  151. <el-button @click="rechargeVisible = false">取 消</el-button>
  152. <el-button type="primary" @click="submitRecharge">确 定</el-button>
  153. </div>
  154. </el-dialog>
  155. </div>
  156. </template>
  157. <script>
  158. import pagination from '@/components/Pagination/index'
  159. import { studentPaymentOrderList, getUserCashAccountBaseInfo, updateCourseBalance,transferCourseBalanceToBalance } from '@/api/studentManager'
  160. import { orderStatus } from '@/utils/searchArray'
  161. import store from '@/store'
  162. export default {
  163. name: 'studentOrder',
  164. components: { pagination },
  165. data () {
  166. return {
  167. rechargeVisible:false,
  168. organId: null,
  169. orderDate: null,
  170. searchForm: {
  171. studentId: null,
  172. orderStartDate: null,
  173. orderEndDate: null,
  174. paymentType: null,
  175. remark: null
  176. },
  177. orderStatus: orderStatus,
  178. pageInfo: {
  179. // 分页规则
  180. limit: 10, // 限制显示条数
  181. page: 1, // 当前页
  182. total: 0, // 总条数
  183. page_size: [10, 20, 40, 50] // 选择限制显示条数
  184. },
  185. tableList: [],
  186. dataInfo: {},
  187. amountStatus: true, // 账户余额状态
  188. rechargeForm:{
  189. money:null
  190. }
  191. }
  192. },
  193. mounted () {
  194. this.searchForm.studentId = this.$route.query.userId
  195. this.getList()
  196. this.__init()
  197. },
  198. activated() {
  199. this.searchForm.studentId = this.$route.query.userId
  200. this.getList()
  201. this.__init()
  202. },
  203. methods: {
  204. onClear (type) {
  205. if (type == 'paymentType') {
  206. this.searchForm.paymentType = null
  207. }
  208. },
  209. __init () {
  210. getUserCashAccountBaseInfo({ userId: this.$route.query.userId }).then(res => {
  211. if (res.code == 200) {
  212. this.dataInfo = {
  213. balance: res.data.balance,
  214. courseBalance: res.data.courseBalance,
  215. wxBalance: 0,
  216. cardNo: res.data.cardNo,
  217. zfb: null
  218. }
  219. }
  220. })
  221. },
  222. onUpdateCourse () {
  223. if (!this.dataInfo.courseBalance) {
  224. this.$message.error('请输入课程余额')
  225. return
  226. }
  227. this.$confirm(`确定是否修改该学生课程余额?`, '提示', {
  228. confirmButtonText: '确定',
  229. cancelButtonText: '取消',
  230. type: 'warning'
  231. }).then(() => {
  232. updateCourseBalance({
  233. userId: this.searchForm.studentId,
  234. decimal: this.dataInfo.courseBalance
  235. }).then(res => {
  236. let result = res.data
  237. if (res.code == 200) {
  238. this.$message.success('保存成功')
  239. this.amountStatus = true
  240. this.__init()
  241. } else {
  242. this.$message.error(res.msg)
  243. }
  244. })
  245. }).catch(() => {
  246. this.amountStatus = true
  247. })
  248. },
  249. search () {
  250. this.pageInfo.page = 1;
  251. this.getList();
  252. },
  253. getList () {
  254. let params = this.searchForm
  255. params.rows = this.pageInfo.limit
  256. params.page = this.pageInfo.page
  257. if (params.remark == '' || !params.remark) {
  258. params.remark = null
  259. }
  260. studentPaymentOrderList(params).then(res => {
  261. if (res.code == 200) {
  262. this.tableList = res.data.rows
  263. this.pageInfo.total = res.data.total
  264. }
  265. })
  266. },
  267. searchCourseDate (value) {
  268. if (value) {
  269. this.searchForm.orderStartDate = value[0]
  270. this.searchForm.orderEndDate = value[1]
  271. } else {
  272. this.searchForm.orderStartDate = null
  273. this.searchForm.orderEndDate = null
  274. }
  275. },
  276. onReSet () { // 重置搜索
  277. this.orderDate = null
  278. this.searchForm = {
  279. studentId: this.$route.query.userId,
  280. orderStartDate: null,
  281. orderEndDate: null,
  282. paymentType: null,
  283. remark: null
  284. }
  285. },
  286. submitRecharge(){
  287. let money = parseFloat(this.dataInfo.courseBalance-this.rechargeForm.money).toFixed(2);
  288. // if(this.rechargeForm)
  289. if(money<0){
  290. this.$message.error('余额不足')
  291. return
  292. }
  293. if(!this.rechargeForm.money){
  294. this.$message.error('请输入金额')
  295. return
  296. }
  297. transferCourseBalanceToBalance({userId:this.searchForm.studentId,money:this.rechargeForm.money}).then(res=>{
  298. if(res.code == 200){
  299. this.$message.success('充值成功')
  300. this.rechargeVisible = false;
  301. this.__init();
  302. }
  303. })
  304. }
  305. }
  306. }
  307. </script>
  308. <style lang="scss" scoped>
  309. .headWrap .left .headItem {
  310. position: relative;
  311. /deep/.el-button {
  312. position: absolute;
  313. top: -3px;
  314. right: 20px;
  315. }
  316. }
  317. // .studentOrder {
  318. // }
  319. </style>