CreateNewspaper.vue 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202
  1. <template>
  2. <div class="manage-root newspaper-create">
  3. <Header />
  4. <div class="manage-root-contain">
  5. <nav-menu class="manage-root-contain-left" :activeMenuIndex="activeMenuIndex"></nav-menu>
  6. <div class="manage-root-contain-right">
  7. <breadcrumb :breadcrumbList="breadcrumbList" class="breadcrumb-box"></breadcrumb>
  8. <div class="create-top">
  9. <div class="common-title-box">
  10. <h3>{{id?'编辑报纸':'创建报纸'}}</h3>
  11. <div class="btn-box" v-if="id||!id&&stepIndex!==2">
  12. <el-button size="small" @click="handleStep('-')" :disabled="stepIndex===0">上一步</el-button>
  13. <el-button type="primary" size="small" @click="handleStep('+')" :disabled="stepIndex===2" :loading="loading">下一步</el-button>
  14. </div>
  15. </div>
  16. <el-steps :active="stepIndex" align-center>
  17. <el-step title="报纸信息" description="填写报纸基本信息">
  18. <svg-icon icon-class="dot" slot="icon" class="svg-dot"></svg-icon>
  19. </el-step>
  20. <el-step title="添加内容" description="为报纸添加内容">
  21. <svg-icon icon-class="dot" slot="icon" class="svg-dot"></svg-icon>
  22. </el-step>
  23. <el-step :title="id?'完成编辑':'完成创建'" :description="id?'报纸编辑完成':'报纸创建完成'">
  24. <svg-icon icon-class="dot" slot="icon" class="svg-dot"></svg-icon>
  25. </el-step>
  26. </el-steps>
  27. </div>
  28. <div class="create-bottom">
  29. <template v-if="stepIndex===0">
  30. <el-form :model="newspaperForm" :rules="rulesNewspaper" ref="newspaperForm" label-width="100px" class="registerForm">
  31. <el-form-item label="报纸封面" prop="cover_image_url">
  32. <upload :datafileList="newspaperForm.cover_image_list" :changeFillId="handleAvatarSuccess" :fileName="'cover'" :showList="true" uploadType="image" :filleNumber="1" v-if="!newspaperForm.cover_image_url" styleType="upload" />
  33. <div class="cover-box" v-else @mouseover="Imagemouseover('coverFlag',true)" @mouseout="Imagemouseover('coverFlag',false)">
  34. <el-image :src="newspaperForm.cover_image_url" fit="cover" style="width:200px;height:280px;"></el-image>
  35. <p v-show="coverFlag" @click="handleDeleteFile('cover',0)"><i class="el-icon-delete"></i></p>
  36. </div>
  37. <p class="tips">建议上传宽高为200*280的图</p>
  38. </el-form-item>
  39. <el-form-item label="报纸名称" prop="iss_name">
  40. <el-input v-model="newspaperForm.iss_name" placeholder="请输入报纸名称" @blur="handleTrim('newspaperForm','iss_name')" maxlength="100"></el-input>
  41. </el-form-item>
  42. <el-form-item label="出版机构" prop="vendor_name">
  43. <el-select v-model="newspaperForm.vendor_name" filterable allow-create default-first-option placeholder="请选择">
  44. <el-option
  45. v-for="(item,i) in vendorList"
  46. :key="item+i"
  47. :label="item"
  48. :value="item">
  49. </el-option>
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item label="是否合刊" required="" prop="comb_flag">
  53. <el-radio-group v-model="newspaperForm.comb_flag">
  54. <el-radio :label="0">否</el-radio>
  55. <el-radio :label="1">是</el-radio>
  56. </el-radio-group>
  57. </el-form-item>
  58. <el-form-item label="期数" prop="iss_no" class="validity-box" v-if="newspaperForm.comb_flag===0">
  59. <el-input placeholder="请输入" v-model="newspaperForm.iss_no" type="number" maxlength="5" @input="$forceUpdate()">
  60. <template slot="append">期</template>
  61. </el-input>
  62. </el-form-item>
  63. <el-form-item label="期数" prop="iss_no_start" v-if="newspaperForm.comb_flag===1">
  64. <el-input v-model="newspaperForm.iss_no_start" style="width:114px" maxlength="20" @input="$forceUpdate()">
  65. </el-input>
  66. <!-- <el-input v-model="newspaperForm.iss_no_end" type="number">
  67. <template slot="append">期</template>
  68. </el-input> -->
  69. </el-form-item>
  70. <el-form-item label="发行日期" prop="release_date">
  71. <el-date-picker
  72. v-model="newspaperForm.release_date"
  73. type="date"
  74. placeholder="选择日期"
  75. value-format="yyyy-MM-dd"
  76. format="yyyy-MM-dd">
  77. </el-date-picker>
  78. </el-form-item>
  79. <el-form-item label="学段" prop="study_phase">
  80. <el-select v-model="newspaperForm.study_phase" placeholder="请选择" @change="getVlList(1)">
  81. <el-option
  82. v-for="item in $studyType"
  83. :key="item.study_phase"
  84. :label="item.study_phase_name"
  85. :value="item.study_phase">
  86. </el-option>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item label="课标词表" prop="vl_id">
  90. <el-select v-model="newspaperForm.vl_id" filterable placeholder="请选择">
  91. <el-option
  92. v-for="item in vlList"
  93. :key="item.id"
  94. :label="item.name"
  95. :value="item.id">
  96. </el-option>
  97. </el-select>
  98. </el-form-item>
  99. <el-form-item label="栏目模板" prop="chn_data">
  100. <el-select v-model="newspaperForm.chn_data" filterable placeholder="请选择" @change="handleChangeChn">
  101. <el-option
  102. v-for="item in tplList"
  103. :key="item.id"
  104. :label="item.tpl_name"
  105. :value="item.chn_data_string">
  106. </el-option>
  107. </el-select>
  108. <a @click="handleLinkChannel" class="tpl-maintain">栏目模板维护</a>
  109. <br/>
  110. <el-input
  111. type="textarea"
  112. :rows="4"
  113. disabled
  114. style="margin-top: 20px"
  115. v-model="newspaperForm.chn_data_str">
  116. </el-input>
  117. </el-form-item>
  118. <el-form-item label="标签" prop="info_tag_data">
  119. <el-select v-model="newspaperForm.info_tag_data" multiple filterable allow-create default-first-option placeholder="请选择">
  120. <el-option
  121. v-for="(item,i) in tabsList"
  122. :key="item+i"
  123. :label="item"
  124. :value="item">
  125. </el-option>
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item label="简介" prop="iss_note">
  129. <el-input
  130. type="textarea"
  131. :rows="4"
  132. placeholder="请输入简介"
  133. v-model="newspaperForm.iss_note"
  134. maxlength="140"
  135. show-word-limit>
  136. </el-input>
  137. </el-form-item>
  138. <!-- <el-form-item label="讲解版" required="" prop="with_addon_flag">
  139. <el-radio-group v-model="newspaperForm.with_addon_flag">
  140. <el-radio :label="0">否</el-radio>
  141. <el-radio :label="1">是</el-radio>
  142. </el-radio-group>
  143. </el-form-item> -->
  144. <!-- <template v-if="newspaperForm.with_addon_flag===1">
  145. <el-divider></el-divider>
  146. <h6>讲解版售价</h6>
  147. <el-form-item label="原价" prop="with_addon_price_org" class="price-box" :key="'with_addon_price'">
  148. <el-input-number v-model="newspaperForm.with_addon_price_org" :min="0" size="small" :precision="2" class="personal-ceil"></el-input-number>
  149. <span class="prepend">¥</span>
  150. <span class="append">元</span>
  151. </el-form-item>
  152. <el-form-item label="优惠价格" prop="has_discount_addon">
  153. <el-radio-group v-model="newspaperForm.has_discount_addon">
  154. <el-radio :label="0">没有</el-radio>
  155. <el-radio :label="1">有</el-radio>
  156. </el-radio-group>
  157. </el-form-item>
  158. <el-form-item label="优惠价格" prop="with_addon_price_sell" class="price-box" v-if="newspaperForm.has_discount_addon===1">
  159. <el-input-number v-model="newspaperForm.with_addon_price_sell" :min="0" size="small" :precision="2" class="personal-ceil"></el-input-number>
  160. <span class="prepend">¥</span>
  161. <span class="append">元</span>
  162. <p class="tips">优惠价格必须低于原价</p>
  163. </el-form-item>
  164. </template>
  165. <el-divider></el-divider>
  166. <h6>普通版售价</h6> -->
  167. <template>
  168. <el-form-item label="原价" prop="iss_price_org" class="price-box" :key="'iss_price'">
  169. <el-input-number v-model="newspaperForm.iss_price_org" :min="0" size="small" :precision="2" class="personal-ceil"></el-input-number>
  170. <span class="prepend">¥</span>
  171. <span class="append">元</span>
  172. </el-form-item>
  173. <el-form-item label="优惠价格" prop="has_discount">
  174. <el-radio-group v-model="newspaperForm.has_discount">
  175. <el-radio :label="0">没有</el-radio>
  176. <el-radio :label="1">有</el-radio>
  177. </el-radio-group>
  178. </el-form-item>
  179. <el-form-item label="优惠价格" prop="iss_price_sell" class="price-box" v-if="newspaperForm.has_discount===1">
  180. <el-input-number v-model="newspaperForm.iss_price_sell" :min="0" size="small" :precision="2" class="personal-ceil"></el-input-number>
  181. <span class="prepend">¥</span>
  182. <span class="append">元</span>
  183. <p class="tips">优惠价格必须低于原价</p>
  184. </el-form-item>
  185. </template>
  186. </el-form>
  187. </template>
  188. <div v-if="stepIndex===1">
  189. <div class="issue-channel" v-if="issueChannel">
  190. <div class="issue-top">
  191. <h4 class="issue-top-left">
  192. 栏目
  193. <span>共 {{issueChannel.chn_count}} 个栏目 {{issueChannel.art_count}} 篇文章</span>
  194. </h4>
  195. <el-button type="primary" size="small">预览</el-button>
  196. </div>
  197. <div class="channel-item" v-for="(item,index) in issueChannel.chn_art_data" :key="index">
  198. <div class="channel-top">
  199. <i class="el-icon-caret-bottom" v-if="item.show" @click="item.show=!item.show"></i>
  200. <i class="el-icon-caret-top" v-else @click="item.show=!item.show"></i>
  201. <div class="channel-top-name">
  202. <template v-if="!item.editFlag">
  203. <span>{{item.chn_name}}</span>
  204. <svg-icon icon-class="edit" class="edit-chn-name" @click="item.editFlag = true"></svg-icon>
  205. </template>
  206. <template v-else>
  207. <el-input v-model="item.edit_name" maxlength="200"></el-input>
  208. <svg-icon icon-class="save-line" class="edit-chn-name" @click="saveChnDate(item.edit_name,index)"></svg-icon>
  209. </template>
  210. </div>
  211. <el-button type="text" @click="handleArticle('',1,item.chn_name)"><i class="el-icon-plus"></i>新增英文内容</el-button>
  212. <el-button type="text" @click="handleArticle('',0,item.chn_name)"><i class="el-icon-plus"></i>新增中文内容</el-button>
  213. </div>
  214. <el-collapse-transition>
  215. <template v-if="item.show">
  216. <draggable
  217. v-model="item.arts"
  218. chosenClass="chosen"
  219. forceFallback="true"
  220. group="people"
  221. animation="1000"
  222. @start="onStart"
  223. @end="onEnd()"
  224. class="article-list"
  225. >
  226. <li v-for="(itema,indexa) in item.arts" :key="indexa">
  227. <svg-icon icon-class="sort" draggable="true"></svg-icon>
  228. <div class="items">
  229. <h6>{{itema.art_title}}</h6>
  230. <span>BY {{itema.art_author}}</span>
  231. <span>创建人:{{itema.creator_real_name||itema.creator_user_name}}</span>
  232. <span>{{itema.create_time}}</span>
  233. </div>
  234. <svg-icon icon-class="edit" class="edit-article" @click="handleArticle(itema.id,itema.en_flag,item.chn_name)"></svg-icon>
  235. <span class="border"></span>
  236. <i class="el-icon-delete" @click="handleDeleteArticle(item.arts,indexa,itema.id)"></i>
  237. </li>
  238. </draggable>
  239. </template>
  240. </el-collapse-transition>
  241. </div>
  242. </div>
  243. </div>
  244. <div v-if="stepIndex===2">
  245. <el-result icon="success" :subTitle="id?'报纸编辑成功':'报纸创建成功'">
  246. <template slot="extra">
  247. <el-button size="small" @click="handleback">返回列表</el-button>
  248. <el-button type="primary" size="small" @click="handleCreate">继续创建</el-button>
  249. </template>
  250. </el-result>
  251. </div>
  252. </div>
  253. </div>
  254. </div>
  255. </div>
  256. </template>
  257. <script>
  258. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  259. //例如:import 《组件名称》from ‘《组件路径》';
  260. import Header from "../../../components/Header.vue";
  261. import NavMenu from "../../../components/NavMenu.vue"
  262. import Breadcrumb from '../../../components/Breadcrumb.vue';
  263. import Upload from "../../../components/Upload.vue"
  264. import { getLogin } from "@/api/ajax";
  265. import { mapState } from 'vuex';
  266. import draggable from "vuedraggable";
  267. export default {
  268. //import引入的组件需要注入到对象中才能使用
  269. components: { Header, NavMenu, Breadcrumb, Upload, draggable },
  270. props: {},
  271. data() {
  272. const validateIssNo = (rule, value, callback) => {
  273. if (value === '') {
  274. callback(new Error('请输入期数'));
  275. } else {
  276. let start = this.newspaperForm.iss_no_start
  277. let end = this.newspaperForm.iss_no_end
  278. if (start!==null&&end!==null) {
  279. if(start>=end){
  280. callback(new Error('开始期数需小于结束期数'));
  281. }else{
  282. callback();
  283. }
  284. } else {
  285. callback(new Error('请输入期数'));
  286. }
  287. }
  288. };
  289. const validatePrice = (rule, value, callback) => {
  290. if (value === '') {
  291. callback(new Error('请输入价格'));
  292. } else {
  293. let price = this.newspaperForm.iss_price_org
  294. let currentPrice = this.newspaperForm.iss_price_sell
  295. if (price!==undefined&&currentPrice!==undefined) {
  296. if(price===0&&rule.fullField==='price'){
  297. callback(new Error('原价需大于0'));
  298. }else if(currentPrice>=price&&this.newspaperForm.has_discount){
  299. callback(new Error('优惠价格必须低于原价'));
  300. }else{
  301. callback();
  302. }
  303. } else {
  304. callback(new Error('请输入'));
  305. }
  306. }
  307. };
  308. const validatePrices = (rule, value, callback) => {
  309. if (value === '') {
  310. callback(new Error('请输入价格'));
  311. } else {
  312. let price = this.newspaperForm.with_addon_price_org
  313. let currentPrice = this.newspaperForm.with_addon_price_sell
  314. if (price!==undefined&&currentPrice!==undefined) {
  315. if(price===0&&rule.fullField==='price'){
  316. callback(new Error('原价需大于0'));
  317. }else if(currentPrice>=price&&this.newspaperForm.has_discount_addon){
  318. callback(new Error('优惠价格必须低于原价'));
  319. }else{
  320. callback();
  321. }
  322. } else {
  323. callback(new Error('请输入'));
  324. }
  325. }
  326. };
  327. const validateIssNoDan = (rule, value, callback) => {
  328. if (value === '') {
  329. callback(new Error('请输入期数'));
  330. } else {
  331. if(value.length>5){
  332. callback(new Error('期数过长'));
  333. }else{
  334. let reg = /^[0-9]*[1-9][0-9]*$/;
  335. let result = reg.test(value);
  336. if (!result) {
  337. callback(new Error('期数只能输入正整数'));
  338. } else {
  339. callback();
  340. }
  341. }
  342. }
  343. };
  344. return {
  345. activeMenuIndex: "newspaper_manage",
  346. breadcrumbList:[
  347. {
  348. icon:'file-list-line',
  349. url:'',
  350. text:''
  351. },
  352. {
  353. icon:'',
  354. url:'',
  355. notLink: true,
  356. text:'内容管理'
  357. },
  358. {
  359. icon:'',
  360. url:'',
  361. text:'报纸管理'
  362. }
  363. ],
  364. id:this.$route.query.id?this.$route.query.id:'',
  365. stepIndex:window.localStorage.getItem('newsStep')?window.localStorage.getItem('newsStep')*1:0, // 步骤索引
  366. coverFlag: false,
  367. newspaperForm:window.localStorage.getItem('newsForm')?JSON.parse(window.localStorage.getItem('newsForm')):{
  368. cover_image_url: '',
  369. cover_image_list: [],
  370. cover_image_id: null,
  371. iss_name: '',
  372. vendor_name: '21世纪报社',
  373. comb_flag: 0,
  374. iss_no: null,
  375. iss_no_start: null,
  376. iss_no_end: null,
  377. release_date: '',
  378. study_phase: null,
  379. vl_id: '',
  380. chn_data: '',
  381. chn_data_str:'',
  382. info_tag_data: [],
  383. iss_note: '',
  384. with_addon_flag: 0,
  385. iss_price_org: null,
  386. iss_price_sell: null,
  387. with_addon_price_org: null,
  388. with_addon_price_sell: null,
  389. has_discount: 1,
  390. has_discount_addon: 1
  391. },
  392. rulesNewspaper:{
  393. iss_name:[
  394. { required: true, message: '请输入报纸名称', trigger: 'blur' }
  395. ],
  396. vendor_name: [
  397. { required: true, message: '请输入出版机构', trigger: 'blur' }
  398. ],
  399. iss_no: [
  400. { required: true, validator: validateIssNoDan, trigger: 'blur' }
  401. ],
  402. iss_no_start: [
  403. { required: true, message: '请输入期数', trigger: 'blur' }
  404. ],
  405. iss_no_end: [
  406. { required: true, validator: validateIssNo, trigger: 'blur' }
  407. ],
  408. study_phase: [
  409. { required: true, message: '请选择学段', trigger: 'change' }
  410. ],
  411. vl_id: [
  412. { required: true, message: '请选择课标词表', trigger: 'change' }
  413. ],
  414. chn_data: [
  415. { required: true, message: '请选择栏目模板', trigger: 'change' }
  416. ],
  417. iss_price_org:[
  418. { required: true, validator: validatePrice, trigger: 'blur' },
  419. ],
  420. iss_price_sell:[
  421. { required: true, validator: validatePrice, trigger: 'blur' },
  422. ],
  423. with_addon_price_org:[
  424. { required: true, validator: validatePrices, trigger: 'blur' },
  425. ],
  426. with_addon_price_sell:[
  427. { required: true, validator: validatePrices, trigger: 'blur' },
  428. ],
  429. },
  430. vendorList: [], // 出版机构列表
  431. vlList: [], // 课标词表
  432. tplList: [], // 栏目列表
  433. tabsList:['中英双语','少儿必读'],
  434. issueId: '',
  435. issueChannel: null,
  436. drag: false,
  437. loading: false
  438. }
  439. },
  440. //计算属性 类似于data概念
  441. computed: {
  442. ...mapState(['$studyType']),
  443. },
  444. //监控data中数据变化
  445. watch: {
  446. },
  447. //方法集合
  448. methods: {
  449. // 上一步下一步
  450. handleStep(type){
  451. if(type=='-'){
  452. if(this.stepIndex>0) this.stepIndex--
  453. }else{
  454. if(this.stepIndex===0){
  455. this.$refs['newspaperForm'].validate((valid) => {
  456. if (valid) {
  457. this.handleAddIssue()
  458. } else {
  459. return false;
  460. }
  461. });
  462. }else if(this.stepIndex===1){
  463. this.handleEditIssue()
  464. }
  465. }
  466. },
  467. // 返回列表
  468. handleback(){
  469. this.$router.push({
  470. path: "/newspaper_manage",
  471. query: {
  472. },
  473. });
  474. },
  475. //继续创建
  476. handleCreate(){
  477. this.$router.replace('/createNewspaper')
  478. location.reload()
  479. },
  480. // 跳转栏目列表
  481. handleLinkChannel(){
  482. window.localStorage.setItem('newsForm',JSON.stringify(this.newspaperForm))
  483. window.localStorage.setItem('newsStep',0)
  484. window.localStorage.setItem('clearForm',true)
  485. this.$router.push({
  486. path:'/channelList'
  487. })
  488. },
  489. handleAvatarSuccess(fileList,name) {
  490. if(name==='cover'){
  491. this.newspaperForm.cover_image_list = fileList
  492. this.newspaperForm.cover_image_id = fileList[0]&&fileList[0].response&&fileList[0].response.file_info_list&&fileList[0].response.file_info_list[0]?fileList[0].response.file_info_list[0].file_id:''
  493. this.newspaperForm.cover_image_url = fileList[0]&&fileList[0].response&&fileList[0].response.file_info_list&&fileList[0].response.file_info_list[0]?fileList[0].response.file_info_list[0].file_url:''
  494. this.$forceUpdate()
  495. }
  496. },
  497. Imagemouseover(item,flag) {
  498. this[item] = flag
  499. },
  500. handleDeleteFile(item,i) {
  501. this.$confirm("确定删除吗?", "提示", {
  502. confirmButtonText: "确定",
  503. cancelButtonText: "取消",
  504. type: "warning",
  505. }).then(() => {
  506. if(item==='cover'){
  507. this.newspaperForm.cover_image_list.splice(i, 1);
  508. this.newspaperForm.cover_image_url = ''
  509. this.newspaperForm.cover_image_id = null
  510. this.$forceUpdate()
  511. }
  512. });
  513. },
  514. handleDeleteArticle(item,i,id){
  515. this.$confirm("确定删除吗?", "提示", {
  516. confirmButtonText: "确定",
  517. cancelButtonText: "取消",
  518. type: "warning",
  519. }).then(() => {
  520. item.splice(i, 1);
  521. getLogin('/PaperServer/Manager/ArticleManager/DeleteArticle', {id:id})
  522. .then((res) => {
  523. if(res.status===1){
  524. }
  525. })
  526. });
  527. },
  528. // 去掉前后空格
  529. handleTrim(form,fild){
  530. this[form][fild] = this[form][fild].trim()
  531. },
  532. // 获取出版机构列表
  533. getVendorList(){
  534. let MethodName = "/PaperServer/Manager/IssueManager/FindVendors";
  535. let data = {
  536. key_word: ''
  537. }
  538. getLogin(MethodName, data)
  539. .then((res) => {
  540. if(res.status===1){
  541. this.vendorList = res.data
  542. }
  543. })
  544. .catch(() => {
  545. });
  546. // getLogin('/PaperServer/Manager/IssueManager/FindPubs', {})
  547. // .then((res) => {
  548. // if(res.status===1){
  549. // }
  550. // })
  551. // .catch(() => {
  552. // });
  553. },
  554. // 课标词表
  555. getVlList(flag){
  556. if(flag){
  557. this.newspaperForm.vl_id = ''
  558. this.newspaperForm.chn_data = ''
  559. this.newspaperForm.chn_data_str = ''
  560. }
  561. let MethodName = "/PaperServer/Manager/VocListManager/FindSimplesByCond";
  562. let data = {
  563. study_phase: this.newspaperForm.study_phase
  564. }
  565. getLogin(MethodName, data)
  566. .then((res) => {
  567. if(res.status===1){
  568. this.vlList = res.data
  569. }
  570. })
  571. .catch(() => {
  572. });
  573. let MethodNames = "/PaperServer/Manager/ChannelTplManager/PickChannelTplByCond";
  574. getLogin(MethodNames, data)
  575. .then((res) => {
  576. if(res.status===1){
  577. let tplList = res.data
  578. tplList.forEach(item => {
  579. item.chn_data_string = JSON.stringify(item.chn_data)
  580. });
  581. this.tplList = tplList
  582. }
  583. })
  584. .catch(() => {
  585. });
  586. },
  587. handleChangeChn(){
  588. this.newspaperForm.chn_data_str = JSON.parse(this.newspaperForm.chn_data).join('\n')
  589. },
  590. handleAddIssue(){
  591. this.loading = true
  592. let MethodName = "/PaperServer/Manager/IssueManager/AddIssue";
  593. let form = this.newspaperForm
  594. let data = {
  595. iss_cover_id: form.cover_image_id,
  596. iss_name: form.iss_name,
  597. vendor_name: form.vendor_name,
  598. release_date: form.release_date,
  599. comb_flag: form.comb_flag,
  600. iss_no:form.comb_flag===0?form.iss_no:form.iss_no_start,
  601. study_phase: form.study_phase,
  602. vl_id: form.vl_id,
  603. iss_price_org: form.iss_price_org,
  604. iss_price_sell: this.newspaperForm.has_discount===1?form.iss_price_sell:form.iss_price_org,
  605. with_addon_price_org: form.with_addon_price_org,
  606. with_addon_price_sell: this.newspaperForm.has_discount_addon===1?form.with_addon_price_sell:form.with_addon_price_org,
  607. iss_note: form.iss_note,
  608. info_tag_data: form.info_tag_data,
  609. chn_data: JSON.parse(form.chn_data),
  610. with_addon_flag: form.with_addon_flag
  611. }
  612. if(this.id||this.issueId){
  613. this.loading = false
  614. this.stepIndex++
  615. return false
  616. }
  617. getLogin(MethodName, data)
  618. .then((res) => {
  619. this.loading = false
  620. if(res.status===1){
  621. window.localStorage.removeItem('newsForm')
  622. window.localStorage.removeItem('newsStep')
  623. window.localStorage.removeItem('clearForm')
  624. this.issueId = res.data.id
  625. this.$router.replace('/createNewspaper?id='+res.data.id+'&isCreate=true')
  626. this.stepIndex++
  627. let chn_art_data = []
  628. if(res.data.chn_art_data){
  629. chn_art_data = JSON.parse(JSON.stringify(res.data.chn_art_data))
  630. chn_art_data.forEach((item,index)=>{
  631. if(index===0){
  632. item.show = true
  633. }else{
  634. item.show = true
  635. }
  636. })
  637. }else{
  638. res.data.chn_data.forEach((itemc,index)=>{
  639. let obj = {
  640. chn_name: itemc,
  641. edit_name: itemc,
  642. arts: [],
  643. show: true
  644. }
  645. chn_art_data.push(obj)
  646. })
  647. }
  648. this.issueChannel = {
  649. chn_count: res.data.chn_count,
  650. art_count: res.data.art_count,
  651. chn_art_data: chn_art_data
  652. }
  653. }
  654. })
  655. .catch(() => {
  656. this.loading = false
  657. });
  658. },
  659. handleEditIssue(){
  660. this.loading = true
  661. let MethodName = "/PaperServer/Manager/IssueManager/EditIssue";
  662. let form = this.newspaperForm
  663. let data = {
  664. iss_cover_id: form.cover_image_id,
  665. iss_name: form.iss_name,
  666. vendor_name: form.vendor_name,
  667. release_date: form.release_date,
  668. comb_flag: form.comb_flag,
  669. iss_no:form.comb_flag===0?form.iss_no:form.iss_no_start,
  670. study_phase: form.study_phase,
  671. vl_id: form.vl_id,
  672. iss_price_org: form.iss_price_org,
  673. iss_price_sell: this.newspaperForm.has_discount===1?form.iss_price_sell:form.iss_price_org,
  674. with_addon_price_org: form.with_addon_price_org,
  675. with_addon_price_sell: this.newspaperForm.has_discount_addon===1?form.with_addon_price_sell:form.with_addon_price_org,
  676. iss_note: form.iss_note,
  677. info_tag_data: form.info_tag_data,
  678. chn_data: JSON.parse(form.chn_data),
  679. with_addon_flag: form.with_addon_flag,
  680. id: this.id?this.id:this.issueId,
  681. chn_art_data: this.issueChannel.chn_art_data
  682. }
  683. getLogin(MethodName, data)
  684. .then((res) => {
  685. this.loading = false
  686. if(res.status===1){
  687. window.localStorage.removeItem('newsForm')
  688. window.localStorage.removeItem('newsStep')
  689. window.localStorage.removeItem('clearForm')
  690. this.stepIndex++
  691. let chn_art_data = []
  692. if(res.data.chn_art_data){
  693. chn_art_data = JSON.parse(JSON.stringify(res.data.chn_art_data))
  694. chn_art_data.forEach((item,index)=>{
  695. if(index===0){
  696. item.show = true
  697. }else{
  698. item.show = true
  699. }
  700. })
  701. }else{
  702. JSON.parse(res.data.chn_data).forEach((itemc,index)=>{
  703. let obj = {
  704. chn_name: itemc,
  705. edit_name: itemc,
  706. arts: [],
  707. show: true
  708. }
  709. chn_art_data.push(obj)
  710. })
  711. }
  712. this.issueChannel = {
  713. chn_count: res.data.chn_count,
  714. art_count: res.data.art_count,
  715. chn_art_data: chn_art_data
  716. }
  717. }
  718. })
  719. .catch(() => {
  720. this.loading = false
  721. });
  722. },
  723. getInfo(){
  724. let MethodName = "/PaperServer/Manager/IssueManager/FindIssueById"
  725. let data = {
  726. id: this.id?this.id:this.issueId
  727. }
  728. getLogin(MethodName, data)
  729. .then((res) => {
  730. if(res.status===1){
  731. this.newspaperForm = res.data
  732. this.newspaperForm.cover_image_list = []
  733. this.newspaperForm.chn_data = JSON.stringify(res.data.chn_data)
  734. this.newspaperForm.chn_data_str = JSON.parse(res.data.chn_data).join('\n')
  735. this.newspaperForm.cover_image_id = res.data.iss_cover_id
  736. this.newspaperForm.iss_no_start = res.data.iss_no
  737. if(res.data.iss_cover_id){
  738. if(res.data.iss_cover_id.indexOf('http')===-1){
  739. getLogin('/FileServer/GetFileInfo', {
  740. file_id: res.data.iss_cover_id
  741. })
  742. .then((res) => {
  743. if(res.status===1){
  744. this.newspaperForm.cover_image_url = res.file_url
  745. this.$forceUpdate()
  746. }
  747. })
  748. }else{
  749. this.newspaperForm.cover_image_url = res.data.iss_cover_id
  750. }
  751. this.newspaperForm.cover_image_list.push[{
  752. id: res.data.iss_cover_id
  753. }]
  754. }
  755. if(res.data.iss_price_org===res.data.iss_price_sell){
  756. this.$set(this.newspaperForm,'has_discount',0)
  757. }else{
  758. this.$set(this.newspaperForm,'has_discount',1)
  759. }
  760. if(res.data.with_addon_price_org===res.data.with_addon_price_sell){
  761. this.$set(this.newspaperForm,'has_discount_addon',0)
  762. }else{
  763. this.$set(this.newspaperForm,'has_discount_addon',1)
  764. }
  765. // let chn_art_data = JSON.parse(JSON.stringify(res.data.chn_art_data))
  766. // chn_art_data.forEach((item,index)=>{
  767. // if(!item.hasOwnProperty('arts')){
  768. // this.$set(item,'arts',[])
  769. // }
  770. // item.editFlag = false
  771. // item.edit_name = item.chn_name
  772. // if(index===0){
  773. // item.show = this.issueChannel&&this.issueChannel.chn_art_data&&this.issueChannel.chn_art_data[index]?this.issueChannel.chn_art_data[index].show:true
  774. // }else{
  775. // item.show = this.issueChannel&&this.issueChannel.chn_art_data&&this.issueChannel.chn_art_data[index]?this.issueChannel.chn_art_data[index].show:false
  776. // }
  777. // })
  778. let chn_art_data = []
  779. if(res.data.chn_art_data){
  780. chn_art_data = JSON.parse(JSON.stringify(res.data.chn_art_data))
  781. chn_art_data.forEach((item,index)=>{
  782. if(!item.hasOwnProperty('arts')){
  783. this.$set(item,'arts',[])
  784. }
  785. item.editFlag = false
  786. item.edit_name = item.chn_name
  787. if(index===0){
  788. item.show = true
  789. }else{
  790. item.show = true
  791. }
  792. })
  793. }else{
  794. JSON.parse(res.data.chn_data).forEach((itemc,index)=>{
  795. if(itemc){
  796. let obj = {
  797. chn_name: itemc,
  798. edit_name: itemc,
  799. arts: [],
  800. show: true
  801. }
  802. chn_art_data.push(obj)
  803. }
  804. })
  805. }
  806. this.issueChannel = {
  807. chn_count: res.data.chn_count,
  808. art_count: res.data.art_count,
  809. chn_art_data: chn_art_data
  810. }
  811. }
  812. })
  813. .catch(() => {
  814. });
  815. },
  816. // 跳转文章
  817. handleArticle(id,type,name){
  818. window.localStorage.setItem('newsForm',JSON.stringify(this.newspaperForm))
  819. window.localStorage.setItem('newsStep',1)
  820. this.$router.push({
  821. path:'/createArticle',
  822. query: {
  823. id: id,
  824. en_flag: type?type:0,
  825. issueId: this.id?this.id:this.issueId,
  826. chn_name: name,
  827. isCreate: this.$route.query.isCreate==='true'?true:''
  828. }
  829. })
  830. },
  831. //开始拖拽事件
  832. onStart(val) {
  833. this.drag = true;
  834. },
  835. //拖拽结束事件
  836. onEnd() {
  837. this.drag = false;
  838. this.issueChannel.chn_art_data.forEach((item)=>{
  839. if(item.arts&&item.arts.length>0){
  840. item.arts.forEach((items,indexs)=>{
  841. items.art_idx = indexs
  842. })
  843. }
  844. })
  845. this.handleUpdateChnArtData()
  846. },
  847. // 更新栏目数据
  848. handleUpdateChnArtData(){
  849. getLogin('/PaperServer/Manager/IssueManager/EditIssueChnArtData', {
  850. chn_art_data: this.issueChannel.chn_art_data,
  851. id: this.id?this.id:this.issueId
  852. })
  853. .then((res) => {
  854. if(res.status===1){
  855. this.getInfo()
  856. }
  857. })
  858. },
  859. saveChnDate(value,index){
  860. // 判断是否有值并且trim
  861. if(value&&value.trim()){
  862. this.issueChannel.chn_art_data[index].chn_name = value.trim()
  863. this.onEnd()
  864. }else{
  865. this.$message.warning('栏目名称不能为空')
  866. }
  867. // if(this.issueChannel.chn_art_data[index].)
  868. }
  869. },
  870. //生命周期 - 创建完成(可以访问当前this实例)
  871. async created() {
  872. this.getVendorList()
  873. await this.getVlList()
  874. let obj = {
  875. icon:'',
  876. url:'',
  877. text:'创建报纸'
  878. }
  879. if(this.$route.query.isCreate==='false'){
  880. obj.text = '编辑报纸'
  881. }
  882. if(this.id){
  883. this.getInfo()
  884. }
  885. this.breadcrumbList.push(obj)
  886. },
  887. //生命周期 - 挂载完成(可以访问DOM元素)
  888. mounted() {
  889. },
  890. //生命周期-创建之前
  891. beforeCreated() { },
  892. //生命周期-挂载之前
  893. beforeMount() { },
  894. //生命周期-更新之前
  895. beforUpdate() { },
  896. //生命周期-更新之后
  897. updated() { },
  898. //生命周期-销毁之前
  899. beforeDestory() { },
  900. //生命周期-销毁完成
  901. destoryed() { },
  902. //如果页面有keep-alive缓存功能,这个函数会触发
  903. activated() { }
  904. }
  905. </script>
  906. <style lang="scss" scoped>
  907. /* @import url(); 引入css类 */
  908. .create-top{
  909. background: #FFFFFF;
  910. border-radius: 4px;
  911. padding: 24px;
  912. .common-title-box{
  913. margin-bottom: 4px;
  914. }
  915. }
  916. .create-bottom{
  917. padding: 40px 40px;
  918. margin-top: 16px;
  919. background: #FFFFFF;
  920. border-radius: 4px;
  921. height: calc(100vh - 292px);
  922. overflow: auto;
  923. .tips{
  924. margin: 0;
  925. color: #86909C;
  926. font-size: 12px;
  927. line-height: 20px;
  928. }
  929. .step-table{
  930. border: 1px solid #E5E6EB;
  931. border-collapse: collapse;
  932. font-size: 14px;
  933. line-height: 22px;
  934. color: #1D2129;
  935. text-align: center;
  936. margin-bottom: 24px;
  937. &-header{
  938. background: #F7F8FA;
  939. width: 120px !important;
  940. color: #86909C;
  941. font-weight: 500;
  942. }
  943. td{
  944. height: 40px;
  945. width: 260px;
  946. border: 1px solid #E5E6EB;
  947. &.td1{
  948. width: 130px;
  949. }
  950. }
  951. .step-cascader{
  952. width: 250px;
  953. height: 32px;
  954. line-height: 32px;
  955. }
  956. }
  957. .tpl-maintain{
  958. margin: 0 16px;
  959. color: #4F75FF;
  960. &:hover{
  961. text-decoration: underline;
  962. }
  963. }
  964. h6{
  965. color: #000;
  966. font-size: 16px;
  967. font-weight: 400;
  968. line-height: 24px;
  969. margin: 0 0 16px 0;
  970. }
  971. }
  972. .cover-box{
  973. position: relative;
  974. width: 200px;
  975. height: 280px;
  976. p{
  977. position: absolute;
  978. bottom: 0;
  979. left: 0;
  980. width: 100%;
  981. height: 280px;
  982. line-height: 280px;
  983. font-size: 20px;
  984. text-align: center;
  985. cursor: pointer;
  986. background: rgba(0, 0, 0, 0.3);
  987. color: #F2F3F5;
  988. margin: 0;
  989. }
  990. }
  991. .issue-channel{
  992. .issue-top{
  993. display: flex;
  994. justify-content: space-between;
  995. margin-bottom: 8px;
  996. &-left{
  997. margin: 0;
  998. color: #1D2129;
  999. font-size: 20px;
  1000. font-weight: 500;
  1001. line-height: 28px;
  1002. span{
  1003. margin-left: 4px;
  1004. color: #86909C;
  1005. font-size: 14px;
  1006. font-weight: 400;
  1007. line-height: 22px;
  1008. }
  1009. }
  1010. }
  1011. .channel-item{
  1012. border: 1px solid #E5E6EB;
  1013. margin: 12px 0;
  1014. .channel-top{
  1015. display: flex;
  1016. padding: 0 12px;
  1017. height: 42px;
  1018. align-items: center;
  1019. .el-icon-caret-bottom,.el-icon-caret-top{
  1020. color: #4E5969;
  1021. width: 14px;
  1022. height: 14px;
  1023. cursor: pointer;
  1024. }
  1025. &-name{
  1026. margin-left: 6px;
  1027. flex: 1;
  1028. word-break: break-word;
  1029. color: #1D2129;
  1030. font-size: 14px;
  1031. font-weight: 400;
  1032. line-height: 22px;
  1033. .edit-chn-name{
  1034. margin-left: 4px;
  1035. cursor: pointer;
  1036. }
  1037. }
  1038. .el-button--text{
  1039. padding: 2px 12px;
  1040. color: #165DFF;
  1041. .el-icon-plus{
  1042. width: 12px;
  1043. height: 12px;
  1044. margin-right: 8px;
  1045. font-weight: bold;
  1046. }
  1047. }
  1048. }
  1049. .article-list{
  1050. margin: 0;
  1051. padding: 8px;
  1052. list-style: none;
  1053. background: #F7F8FA;
  1054. min-height: 44px;
  1055. border-top: 1px solid #E5E6EB;
  1056. li{
  1057. padding: 13px 20px;
  1058. border-bottom: 1px solid #E5E6EB;
  1059. display: flex;
  1060. align-items: center;
  1061. .svg-icon{
  1062. width: 16px;
  1063. height: 16px;
  1064. cursor: move;
  1065. }
  1066. .edit-article{
  1067. cursor: pointer;
  1068. padding: 8px;
  1069. width: 32px;
  1070. height: 48px;
  1071. }
  1072. .items{
  1073. flex: 1;
  1074. margin: 0 16px;
  1075. h6{
  1076. font-size: 16px;
  1077. font-weight: 500;
  1078. line-height: 24px;
  1079. margin-bottom: 2px;
  1080. word-break: break-word;
  1081. }
  1082. span{
  1083. color: #1D2129;
  1084. font-size: 14px;
  1085. font-weight: 400;
  1086. line-height: 22px;
  1087. margin-right: 8px;
  1088. }
  1089. }
  1090. .border{
  1091. height: 12px;
  1092. width: 1px;
  1093. display: block;
  1094. background: #E5E6EB;
  1095. }
  1096. .el-icon-delete{
  1097. font-weight: bold;
  1098. cursor: pointer;
  1099. padding: 8px;
  1100. height: 48px;
  1101. line-height: 32px;
  1102. }
  1103. }
  1104. }
  1105. }
  1106. }
  1107. </style>
  1108. <style lang="scss">
  1109. .newspaper-create{
  1110. .validity-box{
  1111. // width: 114px;
  1112. .el-input-group{
  1113. width: 114px;
  1114. }
  1115. .el-input__inner{
  1116. text-align: center;
  1117. }
  1118. .el-input-group__append{
  1119. border: none;
  1120. background: #F2F3F5;
  1121. padding: 0 8px 0 0;
  1122. }
  1123. }
  1124. .iss-no-box{
  1125. .el-form-item__content{
  1126. display: flex;
  1127. border-radius: 4px;
  1128. width: 164px;
  1129. }
  1130. .el-input-group{
  1131. width: 82px;
  1132. flex-shrink: 0;
  1133. border-radius: 0 4px 4px 0;
  1134. overflow: hidden;
  1135. }
  1136. .el-input__inner{
  1137. border-radius: 0;
  1138. padding: 0;
  1139. text-align: center;
  1140. }
  1141. .el-input-group__append{
  1142. border: none;
  1143. background: #F2F3F5;
  1144. padding: 0;
  1145. border-radius: 0;
  1146. width: 34px;
  1147. text-align: center;
  1148. }
  1149. .iss-start{
  1150. &.el-input-group{
  1151. border-radius: 4px 0 0 4px;
  1152. }
  1153. .el-input-group__append{
  1154. width: 32px;
  1155. }
  1156. }
  1157. }
  1158. input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
  1159. -webkit-appearance: none !important;
  1160. }
  1161. .el-divider{
  1162. width: 600px;
  1163. }
  1164. .price-box{
  1165. width: 300px;
  1166. display: inline-block;
  1167. .el-form-item__content{
  1168. position: relative;
  1169. .prepend,.append{
  1170. position: absolute;
  1171. left: 44px;
  1172. font-size: 14px;
  1173. line-height: 22px;
  1174. color: #1D2129;
  1175. line-height: 34px;
  1176. }
  1177. .append{
  1178. left: 142px;
  1179. }
  1180. }
  1181. }
  1182. .personal-ceil{
  1183. width: 200px;
  1184. .el-input__inner{
  1185. width: 200px;
  1186. padding: 0 60px;
  1187. }
  1188. }
  1189. }
  1190. </style>