timerList.vue 9.0 KB

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