|
|
@@ -0,0 +1,287 @@
|
|
|
+<template>
|
|
|
+ <div class="book org">
|
|
|
+ <ProjectMenu cur-key="org/offlinepackageauth" />
|
|
|
+
|
|
|
+ <el-row>
|
|
|
+ <el-button type="primary" @click="dialogFormEdit = true">创建授权</el-button>
|
|
|
+ </el-row>
|
|
|
+ <el-divider />
|
|
|
+ <div id="query-form">
|
|
|
+ <el-form inline>
|
|
|
+ <el-form-item prop="book_name" label="教材">
|
|
|
+ <el-input v-model="queryForm.book_name" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="auth_code" label="授权码">
|
|
|
+ <el-input v-model="queryForm.auth_code" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="memo" label="备注">
|
|
|
+ <el-input v-model="queryForm.memo" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item class="search-box">
|
|
|
+ <el-button class="search-btn" type="primary" @click="queryList">查询</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div class="book-list">
|
|
|
+ <el-table :data="list">
|
|
|
+ <el-table-column label="序号" width="60" align="center" header-align="center" class-name="index-column">
|
|
|
+ <template slot-scope="{ $index }">
|
|
|
+ {{ cur_page_begin_index + $index }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="book_name" min-width="200" label="教材" />
|
|
|
+ <el-table-column prop="auth_code" label="授权码" width="180" align="center" />
|
|
|
+ <el-table-column prop="effective_count" label="有效次数" width="100" align="right" />
|
|
|
+ <el-table-column label="激活状态" width="100" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ {{ isTrue(row.is_activated) ? '已激活' : '未激活' }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="激活时间" width="120" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <span v-if="isTrue(row.is_activated)" style="color: red">{{ row.effective_end_date }}</span>
|
|
|
+ <span v-else>--</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="有效截止日期" width="120" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <span v-if="isTrue(row.is_disabled)" style="color: red">已废弃</span>
|
|
|
+ <span v-else>{{ row.effective_end_date }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="creator_name" label="创建人" width="120" align="center" />
|
|
|
+ <el-table-column prop="create_time" label="创建时间" width="160" align="center" />
|
|
|
+ <el-table-column label="操作" fixed="right" width="150" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <span class="link" @click="handleDisable(row.id)">废弃</span>
|
|
|
+ <el-divider direction="vertical" />
|
|
|
+ <span class="link" @click="handleDel(row.id)">删除</span>
|
|
|
+ <el-divider direction="vertical" />
|
|
|
+ <span class="link" @click="handleActive('', row.id)">激活</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="memo" label="备注" />
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <PaginationPage :total="total" @getList="pageList" />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-dialog title="创建授权" width="500px" :visible.sync="dialogFormEdit" :close-on-click-modal="false">
|
|
|
+ <el-form ref="editForm" :model="editForm" :rules="rules" label-width="120px">
|
|
|
+ <el-form-item label="教材" prop="book_name">
|
|
|
+ <el-input v-model="editForm.book_name" disabled class="input-with-select" placeholder="请选择教材">
|
|
|
+ <el-button slot="append" icon="el-icon-search" @click="handleSearchBook('')" />
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="有效次数" prop="effective_count">
|
|
|
+ <el-input v-model.number="editForm.effective_count" placeholder="请输入有效次数"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="有效截止日期" prop="effective_end_date">
|
|
|
+ <el-date-picker
|
|
|
+ type="date"
|
|
|
+ placeholder="选择日期"
|
|
|
+ v-model="editForm.effective_end_date"
|
|
|
+ value-format="yyyy-MM-dd"
|
|
|
+ ></el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注" prop="memo">
|
|
|
+ <el-input v-model="editForm.memo" type="textarea" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogFormEdit = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="handleSave('editForm')">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog title="选择教材" width="950px" :visible.sync="dialogSearchBook" :close-on-click-modal="false">
|
|
|
+ <el-table :data="bookList">
|
|
|
+ <el-table-column label="序号" width="60" align="center" header-align="center" class-name="index-column">
|
|
|
+ <template slot-scope="{ $index }">
|
|
|
+ {{ cur_page_begin_index + $index }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="sn" label="编号" width="120" header-align="center" />
|
|
|
+ <el-table-column prop="name" label="名称" min-width="240" header-align="center" />
|
|
|
+ <el-table-column prop="project_sn" label="项目编号" width="120" header-align="center" />
|
|
|
+ <el-table-column prop="project_name" label="项目名称" width="240" header-align="center" />
|
|
|
+ <el-table-column label="操作" width="80">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-button type="primary" @click="selectBook(row)">选择</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <PaginationPage :total="bookTotal" @getList="pageBookList" />
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import ProjectMenu from '@/views/project_manage/common/ProjectMenu.vue';
|
|
|
+import PaginationPage from '@/components/PaginationPage.vue';
|
|
|
+
|
|
|
+import { PageQueryYSJBookList_OrgManager } from '@/api/list';
|
|
|
+import {
|
|
|
+ AddBookOfflinePackAuth,
|
|
|
+ DeleteBookOfflinePackAuth,
|
|
|
+ DisableBookOfflinePackAuth,
|
|
|
+ BookOfflinePackActivate,
|
|
|
+ PageQueryBookOfflinePackAuthList,
|
|
|
+} from '@/api/offline';
|
|
|
+import { isTrue } from '@/utils/validate';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'OrgProjectManageOfflinePackAuth',
|
|
|
+ components: {
|
|
|
+ ProjectMenu,
|
|
|
+ PaginationPage,
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ cur_page_begin_index: 0,
|
|
|
+ bookList: [],
|
|
|
+ bookTotal: 0,
|
|
|
+ bookPageIndex: 0,
|
|
|
+ isTrue,
|
|
|
+ dialogFormEdit: false,
|
|
|
+ dialogSearchBook: false,
|
|
|
+ queryForm: {
|
|
|
+ book_name: '',
|
|
|
+ auth_code: '',
|
|
|
+ memo: '',
|
|
|
+ page_capacity: 10,
|
|
|
+ cur_page: 1,
|
|
|
+ },
|
|
|
+ editForm: {
|
|
|
+ book_id: '',
|
|
|
+ book_name: '',
|
|
|
+ effective_count: null,
|
|
|
+ effective_end_date: '',
|
|
|
+ memo: '',
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ book_name: [{ required: true, message: '请选择教材', trigger: 'blur' }],
|
|
|
+ effective_count: [
|
|
|
+ { required: true, message: '请填写有效次数', trigger: 'blur' },
|
|
|
+ { type: 'number', message: '有效次数必须为数字值' },
|
|
|
+ ],
|
|
|
+ effective_end_date: [{ required: true, message: '请选择有效截止日期', trigger: 'blur' }],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {},
|
|
|
+ watch: {
|
|
|
+ dialogFormEdit: {
|
|
|
+ handler(val) {
|
|
|
+ if (!val) {
|
|
|
+ this.$refs.editForm.resetFields();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ queryList() {
|
|
|
+ this.pageList(this.queryForm);
|
|
|
+ },
|
|
|
+
|
|
|
+ pageList(data) {
|
|
|
+ Object.assign(this.queryForm, data);
|
|
|
+ PageQueryBookOfflinePackAuthList(this.queryForm).then(
|
|
|
+ ({ total_count, offline_pack_auth_list, cur_page_begin_index }) => {
|
|
|
+ this.list = offline_pack_auth_list;
|
|
|
+ this.total = total_count;
|
|
|
+ this.cur_page_begin_index = cur_page_begin_index;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ pageBookList(data) {
|
|
|
+ this.handleSearchBook(data);
|
|
|
+ },
|
|
|
+ handleSearchBook(data) {
|
|
|
+ let page = data || {
|
|
|
+ cur_page: 1,
|
|
|
+ page_capacity: 10,
|
|
|
+ };
|
|
|
+ PageQueryYSJBookList_OrgManager(page).then(({ total_count, book_list, cur_page_begin_index }) => {
|
|
|
+ this.bookList = book_list;
|
|
|
+ this.bookTotal = total_count;
|
|
|
+ this.bookPageIndex = cur_page_begin_index;
|
|
|
+ this.dialogSearchBook = true;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ selectBook(book) {
|
|
|
+ this.editForm.book_name = book.name;
|
|
|
+ this.editForm.book_id = book.id;
|
|
|
+ this.dialogSearchBook = false;
|
|
|
+ },
|
|
|
+ handleSave(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let data = this.editForm;
|
|
|
+ this.dialogSearchBook = false;
|
|
|
+ AddBookOfflinePackAuth(data).then((res) => {
|
|
|
+ if (res && res.status == 1) {
|
|
|
+ this.dialogFormEdit = false;
|
|
|
+ this.queryList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ async handleDisable(id) {
|
|
|
+ this.$confirm('确定要废弃此条数据吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ DisableBookOfflinePackAuth({ id: id }).then(() => {
|
|
|
+ this.queryList();
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+ async handleDel(id) {
|
|
|
+ this.$confirm('确定要删除此条数据吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ DeleteBookOfflinePackAuth({ id: id }).then(() => {
|
|
|
+ this.queryList();
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+ handleActive(id) {
|
|
|
+ BookOfflinePackActivate({ id: id }).then(() => {
|
|
|
+ this.queryList();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+@use '@/styles/mixin.scss' as *;
|
|
|
+
|
|
|
+.book {
|
|
|
+ @include page-base;
|
|
|
+ @include table-list;
|
|
|
+}
|
|
|
+
|
|
|
+.el-divider--horizontal {
|
|
|
+ margin: 10px 0 !important;
|
|
|
+}
|
|
|
+
|
|
|
+.el-form-item__content > * {
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+</style>
|