12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487 |
- <template>
- <div class="container courselist courselistNPC">
- <Header />
- <!-- <Nav navValue="教材列表" /> -->
- <div class="content">
- <div class="inner">
- <div class="btn-box">
- <span @click="handleAdd">
- <img src="../assets/common/icon-add.png" />新建教材
- </span>
- <!-- <el-button @click="handleAdd" size="small" type="primary"
- ><img src="../assets/common/icon-add.png">新建教材</el-button
- >-->
- <!-- <el-input
- @keyup.enter.native="handleSearch"
- placeholder="请输入内容"
- prefix-icon="el-icon-search"
- v-model="searchInput"
- ></el-input>-->
- </div>
- <el-form
- ref="form"
- :inline="true"
- :model="form"
- class="search-form"
- style="margin-left: 10px"
- >
- <el-form-item>
- <el-form-item
- class="label-input"
- label="名称"
- style="margin-right: 30px"
- >
- <el-input v-model="form.name" maxlength="100" />
- </el-form-item>
- <!-- <el-form-item class="label-input" label="作者">
- <el-input v-model="form.author"></el-input>
- </el-form-item>-->
- <el-form-item label="所属机构" style="margin-right: 30px">
- <el-select
- ref="select"
- v-model="form.agency"
- placeholder="请选择机构"
- @change="onSubmit"
- >
- <el-option
- v-for="(statusItem, index) in myOrgList"
- :key="'myOrgList' + index"
- :label="statusItem.org_name"
- :value="statusItem.org_id"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="发布状态">
- <el-select
- v-model="form.publish_status"
- placeholder="请选择状态"
- @change="onSubmit"
- >
- <el-option
- v-for="statusItem in statusList"
- :key="statusItem.value"
- :label="statusItem.label"
- :value="statusItem.value"
- />
- </el-select>
- </el-form-item>
- <el-button size="medium" type="primary" @click="onSubmit"
- >查询</el-button
- >
- </el-form-item>
- </el-form>
- <div class="table-box">
- <el-table
- v-loading="tableloading"
- :data="tableData"
- style="width: 100%"
- @sort-change="handleSort"
- :default-sort = dataSort
- >
- <el-table-column
- class="table-firstC"
- label="名称"
- prop="name"
- width="150"
- sortable='custom'
- />
- <el-table-column label="英文名" prop="name_english" width="150" sortable='custom' />
- <el-table-column label="作者" prop="author" width="100" sortable='custom' />
- <el-table-column label="版本" prop="edition" width="100" />
- <el-table-column label="出版社" prop="publisher" width="150" />
- <el-table-column
- label="出版编号"
- prop="publish_number"
- width="100"
- />
- <el-table-column label="所属机构" prop="org_name" width="150" />
- <el-table-column
- :formatter="handleStatus"
- label="发布状态"
- prop="publish_status"
- width="100"
- />
- <el-table-column
- :formatter="handleScope"
- label="发布范围"
- prop="publish_scope"
- width="100"
- />
- <el-table-column
- label="创建时间"
- prop="create_time"
- width="170"
- sortable='custom'
- />
- <el-table-column fixed="right" label="操作" prop width="370">
- <template slot-scope="scope">
- <el-button type="text" @click="handleClick(scope.row)"
- >编辑</el-button
- >
- <el-button type="text" @click="handleView(scope.row)"
- >预览</el-button
- >
- <el-button
- type="text"
- @click="handleUp(scope.row, scope.$index)"
- >{{
- scope.row.publish_status === 0 ? "上架" : "下架"
- }}</el-button
- >
- <el-button
- type="text"
- @click="handleEdit(scope.row, scope.$index)"
- >教材信息</el-button
- >
- <el-button type="text" @click="handleDiscount(scope.row)"
- >授权码</el-button
- >
- <el-button type="text" @click="handleCreatLink(scope.row)"
- >生成链接</el-button
- >
- <el-button type="text" @click="handleDel(scope.row)"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </div>
- <el-pagination
- :current-page="currentPage"
- :page-size="10"
- :page-sizes="[1, 10, 20, 30, 40, 50]"
- :total="courseTotal"
- layout="total, sizes, prev, pager, next, jumper"
- @current-change="handleCurrentChange"
- @size-change="handleSizeChange"
- />
- </div>
- <div
- id="temporaryLinks"
- style="
- height: 0;
- width: 1200px;
- opacity: 0;
- z-index: -1;
- word-break: break-all;
- "
- ></div>
- </div>
- <el-dialog
- :before-close="handleClose"
- :title="titleEdit"
- :visible.sync="dialogFlag"
- :close-on-click-modal="false"
- >
- <el-form ref="formDialog" :model="formDialog" :rules="courseListRules">
- <el-tabs v-model="activeName">
- <el-tab-pane label="教材信息" name="courseInfo">
- <el-form-item
- class="label-input"
- label="名称"
- label-width="90px"
- prop="name"
- >
- <el-input
- v-model="formDialog.name"
- autocomplete="off"
- name="name"
- maxlength="100"
- show-word-limit
- />
- </el-form-item>
- <el-form-item
- class="label-input"
- label="英文名"
- label-width="90px"
- prop="name_english"
- >
- <el-input
- v-model="formDialog.name_english"
- autocomplete="off"
- name="name_english"
- maxlength="100"
- show-word-limit
- />
- </el-form-item>
- <el-form-item label="教材类型" label-width="90px" prop="type_id">
- <!-- -->
- <el-select
- ref="typeSelects"
- v-model="formDialog.type_id"
- name="bookType"
- placeholder="请选择教材类型"
- >
- <el-option
- v-for="(item, index) in typeList"
- :key="'type' + index"
- :label="item.name"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item
- class="label-input"
- label="作者"
- label-width="90px"
- prop="author"
- >
- <el-input
- v-model="formDialog.author"
- autocomplete="off"
- name="author"
- maxlength="20"
- show-word-limit
- />
- </el-form-item>
- <el-form-item
- class="label-input"
- label="版本"
- label-width="90px"
- prop="edition"
- >
- <el-input
- v-model="formDialog.edition"
- autocomplete="off"
- name="edition"
- maxlength="20"
- show-word-limit
- />
- </el-form-item>
- <el-form-item
- class="label-input"
- label="出版社"
- label-width="90px"
- prop="publisher"
- >
- <el-input
- v-model="formDialog.publisher"
- autocomplete="off"
- name="publisher"
- maxlength="20"
- show-word-limit
- />
- </el-form-item>
- <el-form-item
- class="label-input"
- label="出版编号"
- label-width="90px"
- prop="publish_number"
- >
- <el-input
- v-model="formDialog.publish_number"
- autocomplete="off"
- name="publish_number"
- maxlength="30"
- show-word-limit
- />
- </el-form-item>
- <el-form-item
- class="label-input"
- label="丛书编号"
- label-width="90px"
- prop="series_code"
- >
- <el-input
- autocomplete="off"
- name="series_code"
- v-model="formDialog.series_code"
- maxlength="26"
- show-word-limit
- ></el-input>
- </el-form-item>
- <el-form-item
- class="label-input"
- label="价格"
- label-width="90px"
- prop="price"
- >
- <el-input
- v-model="formDialog.price"
- autocomplete="off"
- name="price"
- type="number"
- @blur="blurPrice"
- @input="inputPrice"
- />
- </el-form-item>
- <el-form-item label="所属机构" label-width="90px" prop="org_id">
- <!-- -->
- <el-select
- ref="selects"
- v-model="formDialog.org_id"
- name="agency"
- placeholder="请选择机构"
- @change="changeAgency"
- >
- <el-option
- v-for="(statusItem, index) in diaMyOrgList"
- :key="'diaMyOrgList' + index"
- :label="statusItem.org_name"
- :value="statusItem.org_id"
- />
- </el-select>
- </el-form-item>
- <el-form-item
- label="教材描述"
- label-width="90px"
- prop="description"
- >
- <el-input
- v-model="formDialog.description"
- type="textarea"
- maxlength="500"
- show-word-limit
- />
- </el-form-item>
- <!-- <el-form-item label="发布状态" label-width="90px">
- <el-radio label="0" v-model="formDialog.publish_status">下架</el-radio>
- <el-radio label="1" v-model="formDialog.publish_status">上架</el-radio>
- </el-form-item>-->
- <!-- <el-form-item
- label="发布范围"
- label-width="90px"
- prop="publish_scope"
- >
- <el-radio v-model="formDialog.publish_scope" :label="1"
- >所有用户可见</el-radio
- >
- <el-radio v-model="formDialog.publish_scope" :label="0"
- >机构内用户可见</el-radio
- >
- </el-form-item> -->
- <el-form-item
- label="主题颜色"
- label-width="90px"
- prop="theme_color"
- >
- <el-radio v-model="formDialog.theme_color" label="red"
- >红色</el-radio
- >
- <el-radio v-model="formDialog.theme_color" label="green"
- >绿色</el-radio
- >
- <el-radio v-model="formDialog.theme_color" label="brown"
- >棕色</el-radio
- >
- </el-form-item>
- <el-form-item label="教材图片" label-width="90px" prop="fileList">
- <el-upload
- :action="url"
- :file-list="fileList"
- :limit="1"
- :before-upload="beforeUpload"
- :on-exceed="handleExceed"
- :on-preview="handlePreview"
- :on-remove="handleRemove"
- :on-success="handleSuccess"
- accept=".jpg, .jpeg, .png"
- class="upload-demo"
- list-type="picture"
- multiple
- style="width: 500px"
- >
- <el-button size="mini" type="success">上传封面</el-button>
- <div
- style="display: inline; padding-left: 30px"
- slot="tip"
- class="el-upload__tip"
- >
- 只能上传.jpg, .jpeg, .png文件,大小不超过2MB
- </div>
- </el-upload>
- </el-form-item>
- </el-tab-pane>
- <el-tab-pane label="教材资源" name="courseResource">
- <el-form-item
- label="视频资源"
- label-width="90px"
- prop="fileListVideo"
- >
- <el-upload
- :action="url"
- :file-list="fileListVideo"
- :limit="100"
- :before-upload="beforeUploadVideo"
- :on-exceed="handleExceedVideo"
- :on-remove="handleRemoveVideo"
- :on-success="handleSuccessVideo"
- :before-remove="beforeRemoveVideo"
- accept="video/*"
- class="upload-demo"
- multiple
- style="width: 500px"
- >
- <el-button size="mini" type="success" :loading="uploadingVideo"
- >上传视频</el-button
- >
- <div
- style="display: inline; padding-left: 30px"
- slot="tip"
- class="el-upload__tip"
- >
- 只能上传视频文件,大小不超过500MB
- </div>
- </el-upload>
- </el-form-item>
- <el-form-item
- label="课文音频"
- label-width="90px"
- prop="fileListAudio"
- >
- <el-upload
- :action="url"
- :file-list="fileListAudio"
- :limit="100"
- :before-upload="beforeUploadAudio"
- :on-exceed="handleExceedVideo"
- :on-remove="handleRemoveAudio"
- :on-success="handleSuccessAudio"
- :before-remove="beforeRemoveVideo"
- accept="audio/*"
- class="upload-demo"
- multiple
- style="width: 500px"
- >
- <el-button size="mini" type="success" :loading="uploadingAudio"
- >上传音频</el-button
- >
- <div
- style="display: inline; padding-left: 30px"
- slot="tip"
- class="el-upload__tip"
- >
- 只能上传音频文件,大小不超过20MB
- </div>
- </el-upload>
- </el-form-item>
- <el-form-item
- label="其他音频"
- label-width="90px"
- prop="fileListOtheraudio"
- >
- <el-upload
- :action="url"
- :file-list="fileListOtheraudio"
- :limit="100"
- :before-upload="beforeUploadOtherAudio"
- :on-exceed="handleExceedVideo"
- :on-remove="handleRemoveOtheraudio"
- :on-success="handleSuccesOthersAudio"
- :before-remove="beforeRemoveVideo"
- accept="audio/*"
- class="upload-demo"
- multiple
- style="width: 500px"
- >
- <el-button
- size="mini"
- type="success"
- :loading="uploadingOtherAudio"
- >上传音频</el-button
- >
- <div
- style="display: inline; padding-left: 30px"
- slot="tip"
- class="el-upload__tip"
- >
- 只能上传音频文件,大小不超过20MB
- </div>
- </el-upload>
- </el-form-item>
- <el-form-item label="试读PDF" label-width="90px" prop="fileListDoc">
- <el-upload
- :action="url"
- :file-list="fileListDoc"
- :limit="100"
- :before-upload="beforeUploadDoc"
- :on-exceed="handleExceedVideo"
- :on-remove="handleRemoveDoc"
- :on-success="handleSuccessDoc"
- :before-remove="beforeRemoveVideo"
- accept=".pdf"
- class="upload-demo"
- multiple
- style="width: 500px"
- >
- <el-button size="mini" type="success" :loading="uploadingDoc"
- >上传PDF</el-button
- >
- <div
- style="display: inline; padding-left: 30px"
- slot="tip"
- class="el-upload__tip"
- >
- 只能上传pdf文件,大小不超过20MB
- </div>
- </el-upload>
- </el-form-item>
- </el-tab-pane>
- </el-tabs>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogFlag = false">取 消</el-button>
- <el-button :loading="loading" type="primary" @click="submitCourse"
- >确 定</el-button
- >
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import Header from "@/components/Header";
- import { validNull, validPrice } from "@/utils/validate";
- // import Nav from "@/components/inputModules/common/Nav";
- import { getContent, getContentFile } from "@/api/ajax";
- import { getToken } from "@/utils/auth";
- export default {
- name: "Courselist",
- components: {
- // Nav,
- Header
- },
- data() {
- const validateNull = (rule, value, callback) => {
- if (!validNull(value)) {
- callback(new Error("请输入相应内容"));
- } else {
- callback();
- }
- };
- const validatePrice = (rule, value, callback) => {
- if (!validPrice(value)) {
- callback(new Error("请输入价格"));
- } else {
- callback();
- }
- };
- return {
- tableData: [], // 数据内容
- currentPage: 1, // 当前页码
- page_capacity: 10, // 每页条数
- courseTotal: 0, // 数据总条数
- searchInput: "", // 搜索内容
- form: {
- author: "",
- status: "",
- agency: "",
- name: "",
- name_english: "",
- edition: "",
- publisher: "",
- publish_number: "",
- series_code: "",
- publish_status: -1
- },
- dialogFlag: false, // 新建教材弹出层
- agency: "",
- formDialog: {
- name: "",
- name_english: "",
- edition: "",
- description: "",
- author: "",
- price: null,
- org_id: "",
- org_name: "",
- publish_scope: 1,
- publish_number: "",
- series_code: "",
- picture_id: "",
- resource_file_id_list_video: [],
- resource_file_id_list_audio: [],
- resource_file_id_list_otheraudio: [],
- resource_file_id_list_doc: [],
- id: "",
- publisher: "",
- theme_color: "",
- type_id: ""
- },
- agencyList: [
- {
- id: "",
- name: "请选择"
- }
- ],
- agencyLists: [
- {
- id: "",
- name: "请选择"
- }
- ],
- publishStatus: {
- 0: "下架",
- 1: "上架"
- },
- publishScope: {
- 0: "机构内用户",
- 1: "所有用户"
- },
- fileList: [], // 上传图片数组
- fileListVideo: [], // 教材资源视频数组
- fileListAudio: [], // 教材资源视频数组
- fileListOtheraudio: [],
- fileListDoc: [], // 教材资源视频数组
- pageIndex: 1,
- courseListRules: {
- // 填写规则
- name: [{ required: true, trigger: "blur", validator: validateNull }],
- author: [{ required: true, trigger: "blur", validator: validateNull }],
- edition: [{ required: true, trigger: "blur", validator: validateNull }],
- publisher: [
- { required: true, trigger: "blur", validator: validateNull }
- ],
- publish_number: [
- { required: true, trigger: "blur", validator: validateNull }
- ],
- org_id: [{ required: true, message: "请选择机构", trigger: "change" }],
- type_id: [
- { required: true, message: "请选择教材类型", trigger: "change" }
- ],
- price: [{ required: true, validator: validatePrice }]
- },
- loading: false,
- uploadingVideo: false,
- uploadingAudio: false,
- uploadingOtherAudio: false,
- uploadingDoc: false,
- titleEdit: "新建教材",
- rowIndex: 0, // 记录编辑教材的index
- tableloading: true,
- selectLoading: false,
- noMore: false,
- statusList: [
- {
- label: "全部",
- value: -1
- },
- {
- label: "上架",
- value: 1
- },
- {
- label: "下架",
- value: 0
- }
- ],
- myOrgList: [
- {
- org_id: "",
- org_name: "全部"
- }
- ],
- diaMyOrgList: [],
- typeList: [],
- activeName: "courseInfo", // 教材信息tabs
- dataSort: localStorage.getItem("dataSort")?JSON.parse(localStorage.getItem("dataSort")):{}
- };
- },
- computed: {
- url() {
- let userInfor = getToken();
- let SessionID = "";
- let UserCode = "";
- let UserType = "";
- if (userInfor) {
- let user = JSON.parse(getToken());
- UserCode = user.user_code;
- UserType = user.user_type;
- SessionID = user.session_id;
- }
- return (
- process.env.VUE_APP_BASE_API +
- "/GCLSFileServer/WebFileUpload?UserCode=" +
- UserCode +
- "&UserType=" +
- UserType +
- "&SessionID=" +
- SessionID +
- "&SecurityLevel=Mid"
- );
- }
- },
- mounted() {
- this.getList();
- this.getTypeList();
- this.getMyOrgList();
- this.getMyOrgListAgree();
- // this.createOptions(1);
- // this.$refs.select.$refs.scrollbar.$refs.wrap.addEventListener(
- // "scroll",
- // this.selectScroll
- // );
- },
- methods: {
- createOptions(len, start = 0) {
- // this.getAgencList();
- },
- selectScroll() {
- let e = this.$refs.select.$refs.scrollbar.$refs.wrap;
- if (this.noMore) return;
- let loadMore = e.scrollHeight - e.scrollTop <= e.clientHeight;
- if (loadMore) {
- this.loadMore();
- }
- },
- loadMore() {
- if (this.selectLoading) return;
- this.selectLoading = true;
- this.getAgencList();
- },
- // 切换每页条数
- handleSizeChange(val) {
- this.currentPage = 1;
- this.page_capacity = val;
- this.getList();
- },
- // 切换页码
- handleCurrentChange(val) {
- this.currentPage = val;
- this.getList();
- },
- // 回车搜索
- handleSearch() {
- console.log(this.searchInput);
- },
- // 点击查询按钮
- onSubmit() {
- this.currentPage = 1;
- this.getList();
- },
- handleClick(row) {
- if (row.publish_status == 1) {
- this.$message({
- type: "warning",
- message: "此教材处于上架状态不可以进行编辑"
- });
- return false;
- }
- sessionStorage.setItem("Bookdetail", JSON.stringify(row));
- this.$router.push("/adultInput?bookId=" + row.id);
- },
- // 预览
- handleView(row) {
- sessionStorage.setItem("Bookdetail", JSON.stringify(row));
- this.$router.push("/courseview?bookId=" + row.id);
- },
- // 授权码
- handleDiscount(row) {
- this.$router.push("/discountCodeList?bookId=" + row.id);
- }, // 生成临时链接
- handleCreatLink(row) {
- var date1 = new Date();
- var date2 = new Date(date1);
- date2.setDate(date1.getDate() + 30);
- let endtime = date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate()
- getContentFile('login_control-CreateValidDateEncryptionString', {
- end_date: endtime,
- })
- .then((res) => {
- let link =
- "https://" +
- window.location.host +
- "/GCLS-Book/#/BookBrowsing?bookId=" +
- row.id+"&encryption="+res.encryption_string;
- document.getElementById("temporaryLinks").innerHTML = link;
- var doc = document,
- text = doc.getElementById("temporaryLinks"),
- range,
- selection;
- if (doc.body.createTextRange) {
- range = doc.body.createTextRange();
- range.moveToElementText(text);
- range.select();
- } else if (window.getSelection) {
- selection = window.getSelection();
- range = doc.createRange();
- range.selectNodeContents(text);
- selection.removeAllRanges();
- selection.addRange(range);
- }
- document.execCommand("copy");
- this.$message({
- message: "复制成功",
- type: "success",
- });
- window.getSelection().removeAllRanges();
- })
- .catch(() => {
- this.$message({
- message: "生成失败,请稍后重试",
- type: "warning",
- });
- });
-
- },
- // 新建教材
- handleAdd() {
- this.titleEdit = "新建教材";
- this.activeName = "courseInfo";
- this.formDialog = {
- name: "",
- name_english: "",
- edition: "",
- description: "",
- author: "",
- price: null,
- org_id: "",
- org_name: "",
- publish_scope: 1,
- publish_number: "",
- series_code: "",
- picture_id: "",
- resource_file_id_list_video: [],
- resource_file_id_list_audio: [],
- resource_file_id_list_otheraudio: [],
- resource_file_id_list_doc: [],
- id: "",
- publisher: "",
- theme_color: "",
- type_id: ""
- };
- this.agency = "";
- this.fileList = [];
- this.fileListVideo = [];
- this.fileListAudio = [];
- this.fileListOtheraudio = [];
- this.fileListDoc = [];
- this.dialogFlag = true;
- },
- // 新建教材提交
- submitCourse() {
- const _this = this;
- if (
- this.uploadingVideo ||
- this.uploadingAudio ||
- this.uploadingOtherAudio ||
- this.uploadingDoc
- ) {
- this.$message.warning("有文件尚未上传成功,请耐心等待");
- return false;
- }
- _this.$refs.formDialog.validate(valid => {
- _this.formDialog.name = _this.formDialog.name.trim();
- _this.formDialog.author = _this.formDialog.author.trim();
- if (_this.formDialog.description !== "") {
- _this.formDialog.description = _this.formDialog.description.trim();
- }
- if (valid) {
- _this.loading = true;
- let MethodName;
- if (_this.formDialog.id) {
- MethodName = "book-book_manager-UpdateBook";
- } else {
- MethodName = "book-book_manager-AddBook";
- }
- // this.formDialog.publish_status = 1;
- this.formDialog.publish_status = this.tableData[this.rowIndex].publish_status ? this.tableData[this.rowIndex].publish_status : 0
- let data = JSON.parse(JSON.stringify(_this.formDialog));
- getContent(MethodName, data)
- .then(res => {
- this.$message.success("操作成功");
- if (_this.formDialog.id) {
- this.$set(_this.tableData, this.rowIndex, data);
- } else {
- _this.currentPage = 1;
- _this.getList();
- _this.resetForm("formDialog");
- }
- _this.dialogFlag = false;
- this.loading = false;
- })
- .catch(() => {
- this.loading = false;
- });
- } else {
- this.loading = false;
- return false;
- }
- });
- },
- // 查询数据列表
- getList() {
- let MethodName = "book-book_manager-PageQueryBookList";
- // let order_column = ""
- // if(this.dataSort != {}){
- // if(this.dataSort.order=='descending'){
- // order_column = this.dataSort.prop + ':desc'
- // }else if(this.dataSort.order=='ascending'){
- // // 升序不传值
- // order_column = this.dataSort.prop
- // }else{
- // order_column = 'create_time:desc'
- // }
- // }else{
- // order_column = 'create_time:desc'
- // }
- let order_column_list = []
- if(this.dataSort != {}){
- if(this.dataSort.order=='descending'){
- order_column_list = [this.dataSort.prop + ':desc']
- }else if(this.dataSort.order=='ascending'){
- // 升序不传值
- order_column_list = [this.dataSort.prop]
- }else{
- order_column_list = ['create_time:desc']
- }
- }else{
- order_column_list = ['create_time:desc']
- }
- let data = {
- name: this.form.name,
- page_capacity: this.page_capacity,
- cur_page: this.currentPage,
- org_id: this.form.agency,
- // order_column: order_column,
- order_column_list:order_column_list,
- publish_status: this.form.publish_status,
- is_control_publish_scope: "false"
- };
- getContent(MethodName, data).then(res => {
- let _this = this;
- _this.tableData = res.book_list;
- _this.courseTotal = res.total_count;
- _this.tableloading = false;
- });
- },
- // 机构列表
- getAgencList() {
- let MethodName = "org_manager-PageQueryOrgList";
- let data = {
- name: "",
- page_capacity: 50,
- cur_page: this.pageIndex
- };
- let dataList = [];
- getContentFile(MethodName, data)
- .then(res => {
- dataList = res.org_list;
- if (this.pageIndex === res.total_page) {
- // 获取到最后的值时,不再监听滚动条的动作,移除滚动事件
- this.$refs.select.$refs.scrollbar.$refs.wrap.removeEventListener(
- "scroll",
- this.selectScroll()
- );
- this.noMore = true;
- }
- this.pageIndex++;
- this.agencyList = this.agencyList.concat(dataList);
- this.agencyLists = this.agencyList;
- })
- .finally(() => (this.selectLoading = false));
- },
- // 得到我的机构列表-org_manager-GetMyOrgList
- getMyOrgList() {
- let MethodName = "org_manager-GetMyOrgList";
- let data = {
- audited_status: 1
- };
- getContentFile(MethodName, data).then(res => {
- if (res && res.org_list.length > 0) {
- this.myOrgList = this.myOrgList.concat(res.org_list);
- this.diaMyOrgList = res.org_list;
- }
- });
- },
- // 得到我的机构列表-org_manager-GetMyOrgList--审核通过的
- getMyOrgListAgree() {
- let MethodName = "org_manager-GetMyOrgList";
- let data = {
- audited_status: 1
- };
- getContentFile(MethodName, data).then(res => {
- if (res && res.org_list.length > 0) {
- this.diaMyOrgList = res.org_list;
- }
- });
- },
- // 教材类型列表
- getTypeList() {
- let MethodName = "dict_manager-GetBookTypeList";
- let data = {};
- getContentFile(MethodName, data).then(res => {
- this.typeList = res.type_list;
- });
- },
- // 处理发布状态
- handleStatus(row) {
- if (row) {
- return this.publishStatus[row.publish_status];
- }
- },
- // 处理发布范围
- handleScope(row) {
- if (row) {
- return this.publishScope[row.publish_scope];
- }
- },
- // 选择机构
- changeAgency(row) {
- for (let i = 0; i < this.diaMyOrgList.length; i++) {
- let item = this.diaMyOrgList[i];
- if (item.org_id === row) {
- this.formDialog.org_name = item.org_name;
- break;
- }
- }
- },
- // 处理教材价格 最多两位小数
- inputPrice(e) {
- e = e.match(/^\d*(\.?\d{0,2})/g)[0] || "";
- this.formDialog.price = e;
- },
- // 处理教材价格 失去焦点保留两位小数
- blurPrice() {
- if (this.formDialog.price) {
- this.formDialog.price = Number(this.formDialog.price).toFixed(2);
- }
- },
- handleSuccess(response, file, fileList) {
- if (response.status == 1) {
- this.$message.success("上传成功");
- this.formDialog.picture_id = response.file_info_list[0].file_id;
- } else {
- this.fileList = [];
- this.$message.warning(response.msg);
- }
- },
- handleSuccessVideo(response, file, fileList) {
- this.uploadingVideo = false;
- if (response.status == 1) {
- this.$message.success("上传成功");
- this.formDialog.resource_file_id_list_video.push(
- response.file_info_list[0].file_id
- );
- } else {
- this.$message.warning(response.msg);
- }
- },
- handleSuccessAudio(response, file, fileList) {
- this.uploadingAudio = false;
- if (response.status == 1) {
- this.$message.success("上传成功");
- this.formDialog.resource_file_id_list_audio.push(
- response.file_info_list[0].file_id
- );
- } else {
- this.$message.warning(response.msg);
- }
- },
- handleSuccesOthersAudio(response, file, fileList) {
- this.uploadingOtherAudio = false;
- if (response.status == 1) {
- this.$message.success("上传成功");
- this.formDialog.resource_file_id_list_otheraudio.push(
- response.file_info_list[0].file_id
- );
- } else {
- this.$message.warning(response.msg);
- }
- },
- handleSuccessDoc(response, file, fileList) {
- this.uploadingDoc = false;
- if (response.status == 1) {
- this.$message.success("上传成功");
- this.formDialog.resource_file_id_list_doc.push(
- response.file_info_list[0].file_id
- );
- } else {
- this.$message.warning(response.msg);
- }
- },
- handleRemove(file, fileList) {
- this.fileList = fileList;
- this.formDialog.picture_id = "";
- },
- handleRemoveVideo(file, fileList) {
- this.fileListVideo = fileList;
- this.formDialog.resource_file_id_list_video = [];
- fileList.forEach(item => {
- this.formDialog.resource_file_id_list_video.push(item.file_id);
- });
- },
- handleRemoveAudio(file, fileList) {
- this.fileListAudio = fileList;
- this.formDialog.resource_file_id_list_audio = [];
- fileList.forEach(item => {
- this.formDialog.resource_file_id_list_audio.push(item.file_id);
- });
- },
- handleRemoveOtheraudio(file, fileList) {
- this.fileListOtheraudio = fileList;
- this.formDialog.resource_file_id_list_otheraudio = [];
- fileList.forEach(item => {
- this.formDialog.resource_file_id_list_otheraudio.push(item.file_id);
- });
- },
- handleRemoveDoc(file, fileList) {
- this.fileListDoc = fileList;
- this.formDialog.resource_file_id_list_doc = [];
- fileList.forEach(item => {
- this.formDialog.resource_file_id_list_doc.push(item.file_id);
- });
- },
- handlePreview(file) {
- console.log(file);
- },
- beforeUpload(file) {
- if (file.size > 2 * 1024 * 1024) {
- this.$message.warning("上传图片大小不能超过2M");
- return false; //必须返回false
- }
- },
- beforeUploadVideo(file) {
- if (this.uploadingVideo) {
- return false;
- } else {
- this.uploadingVideo = true;
- if (file.size > 500 * 1024 * 1024) {
- this.$message.warning("上传视频大小不能超过500M");
- this.uploadingVideo = false;
- return false; //必须返回false
- }
- }
- },
- beforeUploadAudio(file) {
- if (this.uploadingAudio) {
- return false;
- } else {
- this.uploadingAudio = true;
- if (file.size > 20 * 1024 * 1024) {
- this.$message.warning("上传音频大小不能超过20M");
- this.uploadingAudio = false;
- return false; //必须返回false
- }
- }
- },
- beforeUploadOtherAudio(file) {
- if (this.uploadingOtherAudio) {
- return false;
- } else {
- this.uploadingOtherAudio = true;
- if (file.size > 20 * 1024 * 1024) {
- this.$message.warning("上传音频大小不能超过20M");
- this.uploadingOtherAudio = false;
- return false; //必须返回false
- }
- }
- },
- beforeUploadDoc(file) {
- if (this.uploadingDoc) {
- return false;
- } else {
- this.uploadingDoc = true;
- if (file.size > 20 * 1024 * 1024) {
- this.$message.warning("上传文件大小不能超过20M");
- this.uploadingDoc = false;
- return false; //必须返回false
- }
- }
- },
- handleExceed(files, fileList) {
- this.$message.warning(
- `当前限制选择 1 个文件,本次选择了 ${
- files.length
- } 个文件,共选择了 ${files.length + fileList.length} 个文件`
- );
- },
- handleExceedVideo(files, fileList) {
- this.uploadingVideo = false;
- this.uploadingAudio = false;
- this.uploadingOtherAudio = false;
- this.uploadingDoc = false;
- this.$message.warning(
- `当前限制选择 100 个文件,本次选择了 ${
- files.length
- } 个文件,共选择了 ${files.length + fileList.length} 个文件`
- );
- },
- beforeRemoveVideo(file) {
- return this.$confirm(`确定移除 ${file.name}?`);
- },
- // 清空表单
- resetForm(formName) {
- this.$refs[formName].resetFields();
- this.formDialog.price = null;
- this.agency = "";
- this.fileList = [];
- this.fileListVideo = [];
- this.fileListAudio = [];
- this.fileListOtheraudio = [];
- this.fileListDoc = [];
- this.formDialog.description = "";
- },
- // 编辑书籍信息
- handleEdit(row, index) {
- this.$nextTick(() => {
- if (this.$refs["formDialog"] !== undefined) {
- this.$refs["formDialog"].resetFields();
- }
- });
- this.rowIndex = index;
- this.titleEdit = "编辑教材";
- this.activeName = "courseInfo";
- this.fileList = [];
- this.fileListVideo = [];
- this.fileListAudio = [];
- this.fileListOtheraudio = [];
- this.fileListDoc = [];
- let MethodName = "book-book_manager-GetBook";
- let data = {
- id: row.id
- };
- getContent(MethodName, data)
- .then(res => {
- this.formDialog = {
- id: res.id,
- name: res.name,
- description: res.description,
- author: res.author,
- price: res.price.toFixed(2),
- org_id: res.org_id,
- org_name: res.org_name,
- publish_scope: res.publish_scope,
- picture_id: res.picture_id,
- name_english: res.name_english,
- publish_number: res.publish_number,
- series_code: res.series_code,
- publisher: res.publisher,
- theme_color: res.theme_color,
- edition: res.edition,
- type_id: res.type_id
- };
- sessionStorage.setItem("Bookdetail", JSON.stringify(this.formDialog));
- if (res.picture_url) {
- let obj = {
- name: "",
- url: res.picture_url
- };
- this.fileList.push(obj);
- }
- this.agency = res.org_id;
- let MethodNames = "book-resource_manager-GetBookResourceList";
- let datas = {
- book_id: row.id
- };
- getContent(MethodNames, datas).then(res => {
- if (res.status == 1) {
- this.formDialog.resource_file_id_list_video = [];
- this.formDialog.resource_file_id_list_audio = [];
- this.formDialog.resource_file_id_list_otheraudio = [];
- this.formDialog.resource_file_id_list_doc = [];
- res.video_list.forEach(item => {
- let obj = {
- name: item.file_name,
- file_id: item.file_id
- };
- this.fileListVideo.push(obj);
- this.formDialog.resource_file_id_list_video.push(item.file_id);
- });
- res.audio_list.forEach(item => {
- let obj = {
- name: item.file_name,
- file_id: item.file_id
- };
- this.fileListAudio.push(obj);
- this.formDialog.resource_file_id_list_audio.push(item.file_id);
- });
- res.otheraudio_list.forEach(item => {
- let obj = {
- name: item.file_name,
- file_id: item.file_id
- };
- this.fileListOtheraudio.push(obj);
- this.formDialog.resource_file_id_list_otheraudio.push(
- item.file_id
- );
- });
- res.doc_list.forEach(item => {
- let obj = {
- name: item.file_name,
- file_id: item.file_id
- };
- this.fileListDoc.push(obj);
- this.formDialog.resource_file_id_list_doc.push(item.file_id);
- });
- }
- });
- })
- .catch(() => {
- this.loading = false;
- });
- this.dialogFlag = true;
- // 循环select 有没有选中数据 没有插入
- },
- // 删除书籍
- handleDel(row) {
- if (row.publish_status == 1) {
- this.$message({
- type: "warning",
- message: "此教材处于上架状态不可以进行删除"
- });
- return false;
- }
- this.$confirm("确定要删除此书籍吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- let MethodName = "book-book_manager-DeleteBook";
- let data = {
- id: row.id,
- is_force_delete: "true"
- };
- getContent(MethodName, data)
- .then(res => {
- this.currentPage = 1;
- this.getList();
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- })
- .catch(() => {});
- })
- .catch(() => {});
- },
- // 上架
- handleUp(row, index) {
- let Mname = "book-book_manager-SetPublishStatusForBook";
- let updataData = JSON.parse(JSON.stringify(row));
- let data = {
- book_id: row.id
- };
- if (row.publish_status == 0) {
- // 下架状态
- data.publish_status = 1;
- updataData.publish_status = 1;
- } else if (row.publish_status == 1) {
- data.publish_status = 0;
- updataData.publish_status = 0;
- }
- getContent(Mname, data).then(res => {
- this.$message.success("操作成功");
- this.$set(this.tableData, index, updataData);
- });
- },
- // 关闭弹窗
- handleClose(done) {
- this.loading = false;
- this.formDialog.price = null;
- this.agency = "";
- this.fileList = [];
- this.fileListVideo = [];
- this.fileListAudio = [];
- this.fileListOtheraudio = [];
- this.fileListDoc = [];
- this.formDialog.description = "";
- done();
- },
- handleSort(value){
- let dataSort = {
- prop: value.prop,
- order: value.order
- }
- this.dataSort = dataSort
- localStorage.setItem("dataSort", JSON.stringify(dataSort));
- this.getList()
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .container {
- width: 100%;
- background: #f5f5f5;
- .content {
- width: 100%;
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
- max-width: 1200px;
- margin: 0 auto;
- height: auto;
- .inner {
- width: 100%;
- margin: 0 auto;
- box-sizing: border-box;
- padding: 20px 0;
- position: relative;
- .btn-box {
- font-size: 0;
- position: absolute;
- right: 0;
- top: 40px;
- span {
- height: 36px;
- line-height: 36px;
- padding: 0 15px;
- display: flex;
- justify-content: center;
- align-items: center;
- background: #ff9900;
- border-radius: 4px;
- font-size: 14px;
- color: #ffffff;
- cursor: pointer;
- &:hover {
- opacity: 0.8;
- }
- }
- img {
- width: 20px;
- margin-right: 4px;
- }
- }
- .search-form {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- flex-wrap: wrap;
- font-size: 0;
- margin-top: 20px;
- .el-cascader .el-input .el-input__inner {
- width: 240px;
- }
- }
- }
- }
- .el-dialog__body {
- padding-right: 20px;
- }
- .table-box {
- background: #fff;
- padding: 10px 32px 0 32px;
- border-radius: 4px;
- }
- }
- </style>
- <style lang="scss">
- .el-table th.is-leaf {
- border-color: #d5d5d5;
- }
- .el-table td {
- padding: 0.05rem 0;
- }
- .el-dialog {
- font-size: 0;
- }
- .courselistNPC {
- .el-dialog__body {
- padding: 0 20px;
- }
- .el-tabs__nav-wrap::after {
- height: 0;
- }
- .el-upload-list {
- max-height: 400px;
- overflow-y: auto;
- }
- }
- </style>
|