123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- <!-- -->
- <template>
- <div class="m-core">
- <div class="wrap">
- <div class="newBand"
- v-permission="'sysTenantAccount/addMinutes'"
- style="margin-right:20px"
- @click="addTimer">系统充值</div>
- <div class="newBand"
- v-permission="'sysTenantAccount/subtractMinutes'"
- @click="subTimer">系统扣除</div>
- </div>
- <save-form :inline="true"
- class="searchForm"
- save-key='teacherDetail-timerList'
- :model="searchForm" @submit='search' @reset="onReSet">
- <el-form-item>
- <el-select clearable
- placeholder="操作类型"
- v-model="searchForm.transType">
- <el-option :label="item.label"
- :value="item.value"
- v-for="(item,index) in teacherTimeStatus"
- :key="index"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-date-picker style="width: 400px;"
- v-model.trim="searchForm.courseDate"
- type="daterange"
- value-format="yyyy-MM-dd"
- range-separator="至"
- start-placeholder="操作开始日期"
- end-placeholder="操作结束日期"
- :picker-options="{
- firstDayOfWeek: 1
- }"></el-date-picker>
- </el-form-item>
- <el-form-item>
- <el-button native-type="submit"
- type="danger">搜索</el-button>
- <el-button native-type="reset"
- type="primary">重置</el-button>
- </el-form-item>
- </save-form>
- <div style="font-size: 14px; color: #F85043; padding-bottom: 10px;">可用时间:{{ totalTransMinutes }}分钟 </div>
- <div class="tableWrap">
- <el-table :data="tableList"
- :header-cell-style="{background:'#EDEEF0',color:'#444'}">
- <el-table-column align="center"
- prop="updateTime"
- label="操作时间">
- <template slot-scope="scope">
- <div>{{scope.row.updateTime | dateForMinFormat}}</div>
- </template>
- </el-table-column>
- <el-table-column align="center"
- label="操作类型">
- <template slot-scope="scope">
- <div>{{scope.row.transType | transTypeFilter}}</div>
- </template>
- </el-table-column>
- <el-table-column align="center"
- prop="operatorId"
- label="操作人">
- <template slot-scope="scope">
- <div>{{scope.row.operatorId?scope.row.operatorId:scope.row.userId}}</div>
- </template>
- </el-table-column>
- <el-table-column align="center"
- prop="transMinutes"
- label="时间变动/分钟">
- <template slot-scope="scope">
- <div>{{scope.row.transMinutes +'分钟'}}</div>
- </template>
- </el-table-column>
- <el-table-column align="center"
- prop="totalAvailableMinutes"
- label="剩余时间/分钟">
- <template slot-scope="scope">
- <div>{{scope.row.totalAvailableMinutes +'分钟'}}</div>
- </template>
- </el-table-column>
- <el-table-column align="center"
- prop="memo"
- label="备注"></el-table-column>
- </el-table>
- <pagination
- save-key='teacherDetail-timerList'
- sync
- :total.sync="pageInfo.total"
- :page.sync="pageInfo.page"
- :limit.sync="pageInfo.limit"
- :page-sizes="pageInfo.page_size"
- @pagination="getList" />
- </div>
- <el-dialog :title="maskTitle"
- width="440px"
- :visible.sync="timerVisible">
- <el-form :model="timerForm"
- ref="timerForm">
- <el-form-item :label="isAdd?'本次充值':'本次扣除'"
- prop="minutes"
- :rules="[{ required: true, message: '请输入时间' }]">
- <el-row>
- <el-col :span="28">
- <el-input type="number"
- @mousewheel.native.prevent
- v-model.trim="timerForm.minutes"
- @keyup.native="handleInput">
- <template slot="append">分钟</template>
- </el-input>
- </el-col>
- </el-row>
- </el-form-item>
- <el-form-item label="操作备注"
- prop="memo"
- :rules="[{ required: true, message: '请输入备注' }]">
- <el-row>
- <el-col :span="28">
- <el-input type="textarea"
- :rows="3"
- v-model.trim="timerForm.memo"></el-input>
- </el-col>
- </el-row>
- </el-form-item>
- </el-form>
- <div slot="footer"
- class="dialog-footer">
- <el-button @click="timerVisible = false">取 消</el-button>
- <el-button type="primary"
- @click="addTimerSub(isAdd)">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { teacherTimeStatus } from "@/utils/searchArray";
- import pagination from "@/components/Pagination/index";
- import {
- queryTenantAccountList,
- sysTenantAccountAddMinutes,
- sysTenantAccountSubtractMinutes,
- queryTenantAcGet
- } from "@/api/teacherManager";
- export default {
- components: { pagination },
- data () {
- return {
- teacherId: null,
- teacherTimeStatus,
- searchForm: {
- courseDate: [],
- transType: null
- },
- maskTitle: "",
- isAdd: false,
- totalTransMinutes: 0,
- tableList: [],
- timerVisible: false,
- timerForm: {
- minutes: null,
- memo: null
- },
- pageInfo: {
- // 分页规则
- limit: 10, // 限制显示条数
- page: 1, // 当前页
- total: 1, // 总条数
- page_size: [10, 20, 40, 50] // 选择限制显示条数
- }
- };
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created () { },
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted () {
- this.init();
- },
- activated () {
- this.init();
- },
- methods: {
- init () {
- this.teacherId = this.$route.query.teacherId;
- this.getList();
- },
- search () {
- this.pageInfo.page = 1;
- this.getList();
- },
- onReSet () {
- (this.searchForm = {
- courseDate: [],
- transType: null
- }),
- this.search();
- },
- getTime () {
- queryTenantAcGet({ teacherId: this.teacherId }).then(res => {
- if (res.code == 200) {
- if (res.data) {
- this.totalTransMinutes = res.data.availableMinutes;
- }
- }
- });
- },
- getList () {
- let obj = {};
- if (this.searchForm.courseDate && this.searchForm.courseDate.length > 0) {
- obj.startTime = this.searchForm.courseDate[0] + ' 00:00:00';
- obj.endTime = this.searchForm.courseDate[1] + ' 23:59:59';
- }
- this.searchForm.transType
- ? (obj.transType = this.searchForm.transType)
- : null;
- obj.userId = this.teacherId;
- obj.page = this.pageInfo.page;
- obj.rows = this.pageInfo.limit;
- queryTenantAccountList(obj).then(res => {
- if (res.code == 200) {
- this.tableList = res.data.rows;
- this.pageInfo.total = res.data.total;
- }
- });
- this.getTime();
- },
- addTimer () {
- this.isAdd = true;
- this.maskTitle = "充值时间";
- this.timerVisible = true;
- },
- subTimer () {
- this.isAdd = false;
- this.maskTitle = "扣除时间";
- this.timerVisible = true;
- },
- addTimerSub (flag) {
- // true 加时间 false 减时间
- this.$refs["timerForm"].validate(res => {
- if (res) {
- let obj = {
- teacherId: this.teacherId,
- minutes: this.timerForm.minutes,
- memo: this.timerForm.memo
- };
- if (flag) {
- sysTenantAccountAddMinutes(obj).then(res => {
- if (res.code == 200) {
- this.$message.success("添加成功");
- this.timerVisible = false;
- this.getList();
- }
- });
- } else {
- sysTenantAccountSubtractMinutes(obj).then(res => {
- if (res.code == 200) {
- this.$message.success("扣除成功");
- this.timerVisible = false;
- this.getList();
- }
- });
- }
- }
- });
- },
- handleInput () {
- this.timerForm.minutes = this.timerForm.minutes.replace(/[^\.\d]/g, "");
- this.timerForm.minutes = this.timerForm.minutes.replace(".", "");
- }
- },
- watch: {
- timerVisible (val) {
- if (!val) {
- this.timerForm = {
- minutes: null,
- memo: null
- };
- this.$refs["timerForm"].resetFields();
- }
- }
- }
- };
- </script>
- <style lang='scss' scoped>
- .wrap {
- display: flex;
- flex-direction: row;
- justify-content: flex-start;
- }
- /deep/.el-textarea__inner {
- width: 254px;
- }
- </style>
|