|
@@ -1,7 +1,19 @@
|
|
<template>
|
|
<template>
|
|
<div class="oboc">
|
|
<div class="oboc">
|
|
- <div class="oboc-operation">
|
|
|
|
- <el-button type="primary" @click="createLink">创建链接</el-button>
|
|
|
|
|
|
+ <div class="oboc-top">
|
|
|
|
+ <div class="oboc-top-search">
|
|
|
|
+ <span class="search-name">教材名称</span>
|
|
|
|
+ <el-input v-model="book_name" placeholder="请输入教材名称" />
|
|
|
|
+ <span class="search-name">识别码</span>
|
|
|
|
+ <el-input v-model="identity_code" placeholder="请输入识别码" />
|
|
|
|
+ <span class="search-name">备注</span>
|
|
|
|
+ <el-input v-model="memo" placeholder="请输入备注">
|
|
|
|
+ <el-button slot="append" icon="el-icon-search" @click="pageQueryOBOCList" />
|
|
|
|
+ </el-input>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="oboc-top-operation">
|
|
|
|
+ <el-button type="primary" @click="createLink">创建链接</el-button>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<CommonTable
|
|
<CommonTable
|
|
@@ -14,33 +26,37 @@
|
|
@current-change="changePage($event, pageQueryOBOCList)"
|
|
@current-change="changePage($event, pageQueryOBOCList)"
|
|
@size-change="changePageSize($event, pageQueryOBOCList)"
|
|
@size-change="changePageSize($event, pageQueryOBOCList)"
|
|
>
|
|
>
|
|
- <el-table :data="list">
|
|
|
|
- <el-table-column label="类型" width="90" align="center">
|
|
|
|
- <template slot-scope="{ row }">
|
|
|
|
- <span>{{ row.type === 0 ? '试用' : '一书一码' }}</span>
|
|
|
|
- </template>
|
|
|
|
- </el-table-column>
|
|
|
|
|
|
+ <div slot="tab" class="table-tab">
|
|
|
|
+ <span
|
|
|
|
+ v-for="{ label, value } in typeList"
|
|
|
|
+ :key="value"
|
|
|
|
+ :class="{ active: value === type }"
|
|
|
|
+ @click="type = value"
|
|
|
|
+ >{{ label }}</span
|
|
|
|
+ >
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <el-table :data="list" @sort-change="sortChange($event, pageQueryOBOCList)">
|
|
<el-table-column prop="book_name" label="教材" width="240" />
|
|
<el-table-column prop="book_name" label="教材" width="240" />
|
|
<el-table-column prop="identity_code" label="识别码" width="120" />
|
|
<el-table-column prop="identity_code" label="识别码" width="120" />
|
|
- <el-table-column prop="creator_name" label="创建人" width="150" />
|
|
|
|
- <el-table-column prop="create_time" label="创建时间" width="160" />
|
|
|
|
|
|
+ <el-table-column prop="create_time" label="创建时间" width="160" sortable="custom" />
|
|
<el-table-column label="有效天数" width="100">
|
|
<el-table-column label="有效天数" width="100">
|
|
<template slot-scope="{ row }">
|
|
<template slot-scope="{ row }">
|
|
<span>{{ row.effective_day_count === -1 ? '永久' : `${row.effective_day_count}天` }}</span>
|
|
<span>{{ row.effective_day_count === -1 ? '永久' : `${row.effective_day_count}天` }}</span>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column label="到期截止日期" width="140">
|
|
|
|
|
|
+ <el-table-column prop="effective_end_date" label="有效期" width="260" sortable="custom">
|
|
<template slot-scope="{ row }">
|
|
<template slot-scope="{ row }">
|
|
- <span :style="{ color: row.is_disabled === 'true' ? '#CA0000' : '' }">
|
|
|
|
- {{ row.is_disabled === 'true' ? '已废弃' : formateDate(row.effective_end_date) }}
|
|
|
|
- </span>
|
|
|
|
|
|
+ <span :style="{ color: row.is_disabled === 'true' ? '#CA0000' : '' }"> {{ computedPeriod(row) }} </span>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
+ <el-table-column prop="memo" label="备注" />
|
|
|
|
+
|
|
<el-table-column label="操作" fixed="right" width="200">
|
|
<el-table-column label="操作" fixed="right" width="200">
|
|
<template slot-scope="{ row }">
|
|
<template slot-scope="{ row }">
|
|
<span class="set-oboc operable" @click="copyLink(row.url)">复制链接</span>
|
|
<span class="set-oboc operable" @click="copyLink(row.url)">复制链接</span>
|
|
- <span class="set-oboc operable" @click="deleteOBOC(row.id)">删除</span>
|
|
|
|
<span v-if="row.is_disabled !== 'true'" class="set-oboc operable" @click="disableOBOC(row.id)">废弃</span>
|
|
<span v-if="row.is_disabled !== 'true'" class="set-oboc operable" @click="disableOBOC(row.id)">废弃</span>
|
|
|
|
+ <span v-else class="set-oboc operable" @click="deleteOBOC(row.id)">删除</span>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-table>
|
|
@@ -57,7 +73,7 @@ export default {
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-import { ref } from 'vue';
|
|
|
|
|
|
+import { ref, watch } from 'vue';
|
|
|
|
|
|
import { PageQueryOBOCList } from '@/api/list';
|
|
import { PageQueryOBOCList } from '@/api/list';
|
|
import { CreateOBOC, DeleteOBOC, DisableOBOC } from '@/api/oboc';
|
|
import { CreateOBOC, DeleteOBOC, DisableOBOC } from '@/api/oboc';
|
|
@@ -67,14 +83,39 @@ import { Message, MessageBox } from 'element-ui';
|
|
import CommonTable from '@/components/common/CommonTable.vue';
|
|
import CommonTable from '@/components/common/CommonTable.vue';
|
|
import CreateLink from './CreateLink.vue';
|
|
import CreateLink from './CreateLink.vue';
|
|
|
|
|
|
-const { page_capacity, cur_page, total_count, list, changePage, changePageSize } = useList();
|
|
|
|
|
|
+const { page_capacity, cur_page, total_count, list, order_column_list, changePage, changePageSize, sortChange } =
|
|
|
|
+ useList();
|
|
|
|
+
|
|
|
|
+let book_name = ref('');
|
|
|
|
+let identity_code = ref('');
|
|
|
|
+let memo = ref('');
|
|
|
|
+let typeList = [
|
|
|
|
+ {
|
|
|
|
+ label: '试用',
|
|
|
|
+ value: 0
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '一书一码',
|
|
|
|
+ value: 1
|
|
|
|
+ }
|
|
|
|
+];
|
|
|
|
+let type = ref(0);
|
|
|
|
+watch(type, () => {
|
|
|
|
+ pageQueryOBOCList();
|
|
|
|
+});
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 分页查询教材链接列表
|
|
|
|
+ */
|
|
function pageQueryOBOCList() {
|
|
function pageQueryOBOCList() {
|
|
PageQueryOBOCList({
|
|
PageQueryOBOCList({
|
|
page_capacity: page_capacity.value,
|
|
page_capacity: page_capacity.value,
|
|
cur_page: cur_page.value,
|
|
cur_page: cur_page.value,
|
|
- type: -1,
|
|
|
|
- book_name: ''
|
|
|
|
|
|
+ type: type.value,
|
|
|
|
+ book_name: book_name.value,
|
|
|
|
+ identity_code: identity_code.value,
|
|
|
|
+ memo: memo.value,
|
|
|
|
+ order_column_list: order_column_list.value
|
|
}).then(({ oboc_list, total_count: total, cur_page: page }) => {
|
|
}).then(({ oboc_list, total_count: total, cur_page: page }) => {
|
|
list.value = oboc_list;
|
|
list.value = oboc_list;
|
|
total_count.value = total;
|
|
total_count.value = total;
|
|
@@ -93,16 +134,26 @@ function closeCreateLink() {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 创建一书一码
|
|
|
|
- * @param {String} book_id
|
|
|
|
- * @param {Number} type
|
|
|
|
- * @param {Number} effective_day_count
|
|
|
|
|
|
+ * 创建教材链接
|
|
|
|
+ * @param {Object} param0
|
|
|
|
+ * @param {String} param0.book_id
|
|
|
|
+ * @param {Number} param0.type
|
|
|
|
+ * @param {Boolean} param0.is_forever
|
|
|
|
+ * @param {String} param0.effective_date
|
|
|
|
+ * @param {String} param0.memo
|
|
*/
|
|
*/
|
|
-function createOBOC(book_id, type, effective_day_count) {
|
|
|
|
- CreateOBOC({ book_id, type, effective_day_count }).then(() => {
|
|
|
|
|
|
+function createOBOC({ book_id, type, is_forever, effective_date, memo }) {
|
|
|
|
+ CreateOBOC({
|
|
|
|
+ book_id_list: book_id.split(';').filter(id => id.length > 0),
|
|
|
|
+ type,
|
|
|
|
+ is_forever,
|
|
|
|
+ effective_begin_date: effective_date[0],
|
|
|
|
+ effective_end_date: effective_date[1],
|
|
|
|
+ memo
|
|
|
|
+ }).then(() => {
|
|
visible.value = false;
|
|
visible.value = false;
|
|
pageQueryOBOCList();
|
|
pageQueryOBOCList();
|
|
- Message.success(`创建一书一码成功`);
|
|
|
|
|
|
+ Message.success(`创建教材链接成功`);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -113,41 +164,59 @@ function copyLink(url) {
|
|
}
|
|
}
|
|
|
|
|
|
function deleteOBOC(id) {
|
|
function deleteOBOC(id) {
|
|
- MessageBox.confirm('是否删除该一书一码?', '提示', {
|
|
|
|
|
|
+ MessageBox.confirm('是否删除该教材链接?', '提示', {
|
|
confirmButtonText: '确定',
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
type: 'warning'
|
|
}).then(() => {
|
|
}).then(() => {
|
|
DeleteOBOC({ id }).then(() => {
|
|
DeleteOBOC({ id }).then(() => {
|
|
- Message.success(`删除一书一码成功`);
|
|
|
|
|
|
+ Message.success(`删除教材链接成功`);
|
|
pageQueryOBOCList();
|
|
pageQueryOBOCList();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
function disableOBOC(id) {
|
|
function disableOBOC(id) {
|
|
- MessageBox.confirm('是否废弃该一书一码?', '提示', {
|
|
|
|
|
|
+ MessageBox.confirm('是否废弃该教材链接?', '提示', {
|
|
confirmButtonText: '确定',
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
type: 'warning'
|
|
}).then(() => {
|
|
}).then(() => {
|
|
DisableOBOC({ id }).then(() => {
|
|
DisableOBOC({ id }).then(() => {
|
|
pageQueryOBOCList();
|
|
pageQueryOBOCList();
|
|
- Message.success(`废弃一书一码成功`);
|
|
|
|
|
|
+ Message.success(`废弃教材链接成功`);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 将 20241221 转换为 2024年12月21日 格式
|
|
|
|
|
|
+ * 计算有效期
|
|
|
|
+ * @param {Object} row
|
|
|
|
+ */
|
|
|
|
+function computedPeriod({
|
|
|
|
+ is_disabled,
|
|
|
|
+ effective_day_count,
|
|
|
|
+ effective_begin_date = '0000-01-01',
|
|
|
|
+ effective_end_date = '9999-12-31'
|
|
|
|
+}) {
|
|
|
|
+ if (is_disabled === 'true') {
|
|
|
|
+ return '已废弃';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (effective_day_count === -1) {
|
|
|
|
+ return '永久';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return `${formateDate(effective_begin_date.length <= 0 ? '0000-01-01' : effective_begin_date)} ~ ${formateDate(
|
|
|
|
+ effective_end_date
|
|
|
|
+ )}`;
|
|
|
|
+}
|
|
|
|
+/**
|
|
|
|
+ * 将 2024-12-21 转换为 2024年12月21日 格式
|
|
* @param {String} originalDate
|
|
* @param {String} originalDate
|
|
*/
|
|
*/
|
|
function formateDate(originalDate) {
|
|
function formateDate(originalDate) {
|
|
- const dateStr = originalDate.toString();
|
|
|
|
- let year = dateStr.substring(0, 4);
|
|
|
|
- let month = dateStr.substring(4, 6);
|
|
|
|
- let day = dateStr.substring(6, 8);
|
|
|
|
-
|
|
|
|
|
|
+ const [year, month, day] = originalDate.toString().split('-');
|
|
return `${year}年${month}月${day}日`;
|
|
return `${year}年${month}月${day}日`;
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
@@ -161,9 +230,54 @@ function formateDate(originalDate) {
|
|
|
|
|
|
padding: 24px 0 46px;
|
|
padding: 24px 0 46px;
|
|
|
|
|
|
- &-operation {
|
|
|
|
|
|
+ &-top {
|
|
display: flex;
|
|
display: flex;
|
|
align-items: center;
|
|
align-items: center;
|
|
|
|
+
|
|
|
|
+ &-search {
|
|
|
|
+ flex: 1;
|
|
|
|
+
|
|
|
|
+ .search-name {
|
|
|
|
+ width: 80px;
|
|
|
|
+
|
|
|
|
+ & + .el-input {
|
|
|
|
+ width: 200px;
|
|
|
|
+ margin: 0 18px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ &-operation {
|
|
|
|
+ margin-left: 12px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .table-tab {
|
|
|
|
+ position: relative;
|
|
|
|
+ top: 20px;
|
|
|
|
+ display: inline-flex;
|
|
|
|
+ background-color: #fff;
|
|
|
|
+ border: 1px solid #ebeef5;
|
|
|
|
+ border-radius: 10px;
|
|
|
|
+
|
|
|
|
+ span {
|
|
|
|
+ padding: 12px;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+
|
|
|
|
+ &.active {
|
|
|
|
+ color: #fff;
|
|
|
|
+ background-color: #f90;
|
|
|
|
+ border: 1px solid #f90;
|
|
|
|
+
|
|
|
|
+ &:first-child {
|
|
|
|
+ border-radius: 10px 0 0 10px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ &:last-child {
|
|
|
|
+ border-radius: 0 10px 10px 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
.el-table {
|
|
.el-table {
|