timerList.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <!-- -->
  2. <template>
  3. <div class="m-core">
  4. <div class="wrap">
  5. <div class="newBand"
  6. v-permission="'sysTenantAccount/addMinutes'"
  7. style="margin-right:20px"
  8. @click="addTimer">系统充值</div>
  9. <div class="newBand"
  10. v-permission="'sysTenantAccount/subtractMinutes'"
  11. @click="subTimer">系统扣除</div>
  12. </div>
  13. <save-form :inline="true"
  14. class="searchForm"
  15. save-key='teacherDetail-timerList'
  16. :model="searchForm" @submit='search' @reset="onReSet">
  17. <el-form-item>
  18. <el-select clearable
  19. placeholder="操作类型"
  20. v-model="searchForm.transType">
  21. <el-option :label="item.label"
  22. :value="item.value"
  23. v-for="(item,index) in teacherTimeStatus"
  24. :key="index"></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-date-picker style="width: 400px;"
  29. v-model.trim="searchForm.courseDate"
  30. type="daterange"
  31. value-format="yyyy-MM-dd"
  32. range-separator="至"
  33. start-placeholder="操作开始日期"
  34. end-placeholder="操作结束日期"
  35. :picker-options="{
  36. firstDayOfWeek: 1
  37. }"></el-date-picker>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button native-type="submit"
  41. type="danger">搜索</el-button>
  42. <el-button native-type="reset"
  43. type="primary">重置</el-button>
  44. </el-form-item>
  45. </save-form>
  46. <div style="font-size: 14px; color: #F85043; padding-bottom: 10px;">可用时间:{{ totalTransMinutes }}分钟 &nbsp;&nbsp;&nbsp;&nbsp;</div>
  47. <div class="tableWrap">
  48. <el-table :data="tableList"
  49. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  50. <el-table-column align="center"
  51. prop="updateTime"
  52. label="操作时间">
  53. <template slot-scope="scope">
  54. <div>{{scope.row.updateTime | dateForMinFormat}}</div>
  55. </template>
  56. </el-table-column>
  57. <el-table-column align="center"
  58. label="操作类型">
  59. <template slot-scope="scope">
  60. <div>{{scope.row.transType | transTypeFilter}}</div>
  61. </template>
  62. </el-table-column>
  63. <el-table-column align="center"
  64. prop="operatorId"
  65. label="操作人">
  66. <template slot-scope="scope">
  67. <div>{{scope.row.operatorId?scope.row.operatorId:scope.row.userId}}</div>
  68. </template>
  69. </el-table-column>
  70. <el-table-column align="center"
  71. prop="transMinutes"
  72. label="时间变动/分钟">
  73. <template slot-scope="scope">
  74. <div>{{scope.row.transMinutes +'分钟'}}</div>
  75. </template>
  76. </el-table-column>
  77. <el-table-column align="center"
  78. prop="totalAvailableMinutes"
  79. label="剩余时间/分钟">
  80. <template slot-scope="scope">
  81. <div>{{scope.row.totalAvailableMinutes +'分钟'}}</div>
  82. </template>
  83. </el-table-column>
  84. <el-table-column align="center"
  85. prop="memo"
  86. label="备注"></el-table-column>
  87. </el-table>
  88. <pagination
  89. save-key='teacherDetail-timerList'
  90. sync
  91. :total.sync="pageInfo.total"
  92. :page.sync="pageInfo.page"
  93. :limit.sync="pageInfo.limit"
  94. :page-sizes="pageInfo.page_size"
  95. @pagination="getList" />
  96. </div>
  97. <el-dialog :title="maskTitle"
  98. width="440px"
  99. :visible.sync="timerVisible">
  100. <el-form :model="timerForm"
  101. ref="timerForm">
  102. <el-form-item :label="isAdd?'本次充值':'本次扣除'"
  103. prop="minutes"
  104. :rules="[{ required: true, message: '请输入时间' }]">
  105. <el-row>
  106. <el-col :span="28">
  107. <el-input type="number"
  108. @mousewheel.native.prevent
  109. v-model.trim="timerForm.minutes"
  110. @keyup.native="handleInput">
  111. <template slot="append">分钟</template>
  112. </el-input>
  113. </el-col>
  114. </el-row>
  115. </el-form-item>
  116. <el-form-item label="操作备注"
  117. prop="memo"
  118. :rules="[{ required: true, message: '请输入备注' }]">
  119. <el-row>
  120. <el-col :span="28">
  121. <el-input type="textarea"
  122. :rows="3"
  123. v-model.trim="timerForm.memo"></el-input>
  124. </el-col>
  125. </el-row>
  126. </el-form-item>
  127. </el-form>
  128. <div slot="footer"
  129. class="dialog-footer">
  130. <el-button @click="timerVisible = false">取 消</el-button>
  131. <el-button type="primary"
  132. @click="addTimerSub(isAdd)">确 定</el-button>
  133. </div>
  134. </el-dialog>
  135. </div>
  136. </template>
  137. <script>
  138. import { teacherTimeStatus } from "@/utils/searchArray";
  139. import pagination from "@/components/Pagination/index";
  140. import {
  141. queryTenantAccountList,
  142. sysTenantAccountAddMinutes,
  143. sysTenantAccountSubtractMinutes,
  144. queryTenantAcGet
  145. } from "@/api/teacherManager";
  146. export default {
  147. components: { pagination },
  148. data () {
  149. return {
  150. teacherId: null,
  151. teacherTimeStatus,
  152. searchForm: {
  153. courseDate: [],
  154. transType: null
  155. },
  156. maskTitle: "",
  157. isAdd: false,
  158. totalTransMinutes: 0,
  159. tableList: [],
  160. timerVisible: false,
  161. timerForm: {
  162. minutes: null,
  163. memo: null
  164. },
  165. pageInfo: {
  166. // 分页规则
  167. limit: 10, // 限制显示条数
  168. page: 1, // 当前页
  169. total: 1, // 总条数
  170. page_size: [10, 20, 40, 50] // 选择限制显示条数
  171. }
  172. };
  173. },
  174. //生命周期 - 创建完成(可以访问当前this实例)
  175. created () { },
  176. //生命周期 - 挂载完成(可以访问DOM元素)
  177. mounted () {
  178. this.init();
  179. },
  180. activated () {
  181. this.init();
  182. },
  183. methods: {
  184. init () {
  185. this.teacherId = this.$route.query.teacherId;
  186. this.getList();
  187. },
  188. search () {
  189. this.pageInfo.page = 1;
  190. this.getList();
  191. },
  192. onReSet () {
  193. (this.searchForm = {
  194. courseDate: [],
  195. transType: null
  196. }),
  197. this.search();
  198. },
  199. getTime () {
  200. queryTenantAcGet({ teacherId: this.teacherId }).then(res => {
  201. if (res.code == 200) {
  202. if (res.data) {
  203. this.totalTransMinutes = res.data.availableMinutes;
  204. }
  205. }
  206. });
  207. },
  208. getList () {
  209. let obj = {};
  210. if (this.searchForm.courseDate && this.searchForm.courseDate.length > 0) {
  211. obj.startTime = this.searchForm.courseDate[0] + ' 00:00:00';
  212. obj.endTime = this.searchForm.courseDate[1] + ' 23:59:59';
  213. }
  214. this.searchForm.transType
  215. ? (obj.transType = this.searchForm.transType)
  216. : null;
  217. obj.userId = this.teacherId;
  218. obj.page = this.pageInfo.page;
  219. obj.rows = this.pageInfo.limit;
  220. queryTenantAccountList(obj).then(res => {
  221. if (res.code == 200) {
  222. this.tableList = res.data.rows;
  223. this.pageInfo.total = res.data.total;
  224. }
  225. });
  226. this.getTime();
  227. },
  228. addTimer () {
  229. this.isAdd = true;
  230. this.maskTitle = "充值时间";
  231. this.timerVisible = true;
  232. },
  233. subTimer () {
  234. this.isAdd = false;
  235. this.maskTitle = "扣除时间";
  236. this.timerVisible = true;
  237. },
  238. addTimerSub (flag) {
  239. // true 加时间 false 减时间
  240. this.$refs["timerForm"].validate(res => {
  241. if (res) {
  242. let obj = {
  243. teacherId: this.teacherId,
  244. minutes: this.timerForm.minutes,
  245. memo: this.timerForm.memo
  246. };
  247. if (flag) {
  248. sysTenantAccountAddMinutes(obj).then(res => {
  249. if (res.code == 200) {
  250. this.$message.success("添加成功");
  251. this.timerVisible = false;
  252. this.getList();
  253. }
  254. });
  255. } else {
  256. sysTenantAccountSubtractMinutes(obj).then(res => {
  257. if (res.code == 200) {
  258. this.$message.success("扣除成功");
  259. this.timerVisible = false;
  260. this.getList();
  261. }
  262. });
  263. }
  264. }
  265. });
  266. },
  267. handleInput () {
  268. this.timerForm.minutes = this.timerForm.minutes.replace(/[^\.\d]/g, "");
  269. this.timerForm.minutes = this.timerForm.minutes.replace(".", "");
  270. }
  271. },
  272. watch: {
  273. timerVisible (val) {
  274. if (!val) {
  275. this.timerForm = {
  276. minutes: null,
  277. memo: null
  278. };
  279. this.$refs["timerForm"].resetFields();
  280. }
  281. }
  282. }
  283. };
  284. </script>
  285. <style lang='scss' scoped>
  286. .wrap {
  287. display: flex;
  288. flex-direction: row;
  289. justify-content: flex-start;
  290. }
  291. /deep/.el-textarea__inner {
  292. width: 254px;
  293. }
  294. </style>