carousel.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. <script>
  2. import axios from "axios";
  3. import {defineComponent} from "vue";
  4. import fieldIsAllow from "../../../until/fieldIsAllow"
  5. import RoundedTitle from "../../../components/public/roundedTitle.vue";
  6. import {rCode} from "../../../map/rcodeMap_esm";
  7. import handle from "../../../until/handle";
  8. import ImageViewer from "../../../components/public/imageViewer.vue";
  9. import ImageTable from "../../../components/public/imageTable.vue";
  10. import Pop from "../../../components/public/pop.vue";
  11. import PopCard from "../../../components/public/popCard.vue";
  12. import InputRow from "../../../components/public/form/inputRow.vue";
  13. import dbField_esm from "../../../map/dbField_esm";
  14. import {apiMap} from "../../../map/apiMap";
  15. import SearchBox from "../../../components/search/searchBox.vue";
  16. import {pTypes} from "../../../map/productMap";
  17. import {newsType} from "../../../map/newMap";
  18. import {toNumber} from "../../../until/typeTool";
  19. import {isEmpty} from "../../../server/tools/typeTool_cjs";
  20. export default defineComponent({
  21. name: 'carousel',
  22. computed: {
  23. dbField_esm() {
  24. return dbField_esm
  25. },
  26. productTypes(){
  27. let arr = this.$store.getters.productTypes;
  28. // 添加 all
  29. arr.unshift({text: '全部', key: 'all' });
  30. return arr;
  31. },
  32. newsTypes(){// 添加 all
  33. let arr = this.$store.getters.allNewsTypes;
  34. arr.unshift({text: '全部', key: 'all' });
  35. return arr;
  36. },
  37. },
  38. components: {SearchBox, InputRow, PopCard, Pop, ImageTable, ImageViewer, RoundedTitle},
  39. async asyncData(ctx){
  40. // 加载轮播图数据
  41. let [err,res] = await handle(axios.get(apiMap.carouselList.path));
  42. if(err){
  43. return {};
  44. }
  45. let result = res.data;
  46. if(result.code === rCode.OK){
  47. return {carouselList: result.data}
  48. }else{
  49. this.$message.error(result.msg);
  50. return {}
  51. }
  52. return {}
  53. },
  54. data(){
  55. return {
  56. limit: 10,
  57. loading: false,
  58. carouselList: [],
  59. popShow: false,
  60. popLoading: false,
  61. carouselPopShow: false,
  62. carouselPopLoading: false,
  63. isEditCarousel: false,
  64. carouselData: {},
  65. form: {
  66. // 排序
  67. sort: {
  68. val:0,
  69. init: 0,
  70. msg: '',
  71. state: 0,
  72. },
  73. // 状态 0:禁用,1:启用
  74. state: {
  75. val: dbField_esm.db_base.carouselState.disable,
  76. init: dbField_esm.db_base.carouselState.disable,
  77. msg: '',
  78. state: 0,
  79. options: [
  80. {label: '禁用', value: dbField_esm.db_base.carouselState.disable},
  81. {label: '启用', value: dbField_esm.db_base.carouselState.enable},
  82. ]
  83. },
  84. // 轮播类型 '0:product','1:news','2:page','3:href'
  85. type: {
  86. val: 0,
  87. init: 0,
  88. msg: '',
  89. state: 0,
  90. options: [
  91. {label: '直接链接', value: 0,checkField: 'href'},
  92. {label: '内部产品', value: 1,checkField: 'productId'},
  93. {label: '指向新闻', value: 2,checkField: 'newsId'},
  94. ],
  95. },
  96. // 具体值
  97. value: {
  98. val: '',
  99. init: '',
  100. msg: '',
  101. state: 0,
  102. // 依赖字段
  103. depend: 'type',
  104. showText: '',// 展示用字段
  105. oldShowText: '',
  106. },
  107. // file
  108. fileData: {
  109. val: '',
  110. init: '',
  111. msg: '',
  112. state: 0,
  113. showText: '',// 展示用字段
  114. oldShowText: '',
  115. },
  116. },
  117. productSelectVisible: false,
  118. productSearch: {
  119. type: {
  120. val: '',
  121. oldVal: '',
  122. init: '',
  123. msg: '',
  124. options: [],
  125. }
  126. },
  127. newsSelectVisible: false,
  128. newsVisible: false,
  129. newsSearch: {
  130. type: {
  131. val: '',
  132. oldVal: '',
  133. init: '',
  134. msg: '',
  135. options: [],
  136. }
  137. },
  138. imageSelectVisible: false,
  139. }
  140. },
  141. mounted() {
  142. if(this.carouselList.length === 0){
  143. this.getCarouselList();
  144. }
  145. },
  146. methods: {
  147. async getCarouselList(){
  148. this.loading = true;
  149. let [err,res] = await handle(this.$axios.get(apiMap.carouselAllList.path));
  150. this.loading = false;
  151. if(err){
  152. if(this.NotificationKey){
  153. this.$notification.close(this.NotificationKey);
  154. }
  155. this.NotificationKey = `open${Date.now()}`;
  156. return this.$notification.error({
  157. message: '轮播数据加载失败',
  158. description:`异常: ${err.message}`,
  159. duration: 0,
  160. btn: h => {
  161. return h(
  162. 'a-button',
  163. {
  164. props: {
  165. type: 'primary',
  166. size: 'small',
  167. },
  168. on: {
  169. click: () => {
  170. this.$notification.close(this.NotificationKey);
  171. this.getCarouselList();
  172. },
  173. },
  174. },
  175. '重试',
  176. );
  177. },
  178. key:this.NotificationKey,
  179. onClose: close,
  180. });
  181. }
  182. let result = res.data;
  183. if(result.code === rCode.OK){
  184. this.carouselList = result.data;
  185. return {carouselList: result.data}
  186. }else{
  187. this.$message.error(result.msg);
  188. return {}
  189. }
  190. },
  191. // 搜索产品,只需要产品名等信息
  192. async getProductSearch(searchParam){
  193. console.log(searchParam)
  194. if(this.productSearch.type.val !== this.productSearch.type.oldVal){
  195. searchParam.p = 1;
  196. }
  197. searchParam.type = this.productSearch.type.val;
  198. searchParam.l = this.limit;
  199. searchParam.p = searchParam.page;
  200. let [err,res] = await handle(
  201. this.$axios.get(
  202. apiMap.searchProductMini.path,
  203. {params:searchParam})
  204. );
  205. if(err){
  206. console.log(err);
  207. return [{message:'请求数据失败'},null];
  208. }
  209. let result = res.data;
  210. if(result.code === rCode.OK){
  211. this.productSearch.type.oldVal = this.productSearch.type.val;
  212. // data 转换
  213. result.data = result.data.map(item=>{
  214. item.showText=item.name;
  215. return item;
  216. });
  217. return [null,result];
  218. }else{
  219. // 可捕获的服务器错误
  220. return [{message:result.msg},null];
  221. }
  222. },
  223. // 加载轮播默认数据
  224. async getNewsSearch(searchParam){
  225. console.log(searchParam)
  226. if(this.newsSearch.type.val !== this.newsSearch.type.oldVal){
  227. searchParam.p = 1;
  228. }
  229. searchParam.type = this.newsSearch.type.val;
  230. searchParam.l = this.limit;
  231. searchParam.p = searchParam.page;
  232. let [err,res] = await handle(
  233. this.$axios.get(
  234. apiMap.searchNewsMini.path,
  235. {params:searchParam})
  236. );
  237. if(err){
  238. console.log(err);
  239. return [{message:'请求数据失败'},null];
  240. }
  241. let result = res.data;
  242. if(result.code === rCode.OK){
  243. this.newsSearch.type.oldVal = this.newsSearch.type.val;
  244. // data 转换
  245. result.data = result.data.map(item=>{
  246. item.showText=item.name;
  247. return item;
  248. });
  249. return [null,result];
  250. }else{
  251. // 可捕获的服务器错误
  252. return [{message:result.msg},null];
  253. }
  254. },
  255. checkFormItem(field,enumOptions,reCheckField){
  256. let formItem = this.form[field];
  257. if (formItem){
  258. if (enumOptions){
  259. // 遍历枚举
  260. for (let i = 0; i < enumOptions.length; i++) {
  261. let enumOption = enumOptions[i];
  262. if (enumOption.value === formItem.val){
  263. return true;
  264. }
  265. }
  266. formItem.msg = '选项不在范围内';
  267. return false;
  268. }
  269. if(reCheckField){
  270. // 检查用字段
  271. formItem.msg = fieldIsAllow({
  272. [reCheckField]:formItem.val,
  273. })
  274. }else{
  275. formItem.msg = fieldIsAllow({
  276. [field]:formItem.val,
  277. })
  278. }
  279. }else{
  280. let r = true;
  281. for (const fieldKey in this.form) {
  282. formItem = this.form[fieldKey];
  283. let depend = this.form[formItem.depend];
  284. let checkField = fieldKey;
  285. if(formItem.reCheckField){
  286. checkField = formItem.reCheckField;
  287. }
  288. // 枚举值判断
  289. if(formItem.options){
  290. // 有枚举字段,只判断是否在枚举中
  291. if(formItem.options.findIndex(item=>item.value == formItem.val) === -1){
  292. formItem.msg = '选项不在范围内';
  293. r = false;
  294. }
  295. // 枚举值判断完毕,继续下一个字段
  296. continue;
  297. }
  298. // 判断是否有依赖字段
  299. if(depend){
  300. if(depend.options){
  301. // 依赖的对象有枚举类型,检查该枚举类型是否有有检测值
  302. let optionItem = depend.options.find(item=>item.value == depend.val);
  303. if(!optionItem){
  304. depend.msg = '选项不在范围内';
  305. formItem.msg = '该值依赖项输入异常';
  306. r = false;
  307. continue;
  308. }
  309. if(optionItem.checkField){
  310. console.log(`采用依赖项的检测字段${optionItem.checkField}`)
  311. checkField = optionItem.checkField;
  312. }
  313. }
  314. }
  315. console.log(`检测字段:${checkField},值:${formItem.val}`);
  316. formItem.msg = fieldIsAllow({
  317. [checkField]:formItem.val,
  318. })
  319. if (formItem.msg){
  320. r = false;
  321. }
  322. }
  323. return r
  324. }
  325. },
  326. initCarouseForm(){
  327. this.carouselData = {};
  328. let keys = Object.keys(this.form);
  329. for(let i = 0; i < keys.length; i++){
  330. let key = keys[i];
  331. this.form[key].val = this.form[key].init;
  332. this.form[key].msg = '';
  333. this.form[key].state = 0;
  334. this.form.value.showText = '';
  335. }
  336. },
  337. openAddCarouselModal(){
  338. // 初始化表单
  339. this.initCarouseForm();
  340. this.carouselPopShow = true;
  341. this.isEditCarousel = false;
  342. this.$nextTick(()=>{
  343. // 打开弹窗. 选择图片,填写链接地址,排序
  344. this.productSearch.type.options = this.productTypes;
  345. this.newsSearch.type.options = this.newsTypes;
  346. // 默认值设置
  347. this.productSearch.type.val = this.productTypes[0].key;
  348. this.productSearch.type.oldVal = this.productTypes[0].key;
  349. this.productSearch.type.init = this.productTypes[0].key;
  350. this.newsSearch.type.val = this.newsTypes[0].key;
  351. this.newsSearch.type.oldVal = this.newsTypes[0].key;
  352. this.newsSearch.type.init = this.newsTypes[0].key;
  353. });
  354. },
  355. onPopOkClickHandle(){
  356. if(this.isEditCarousel){
  357. console.log('保存修改后的轮播数据');
  358. this.updateCarouselExecute();
  359. }else{
  360. console.log('新增轮播图');
  361. this.addCarouselExecute();
  362. }
  363. },
  364. async addCarouselExecute(){
  365. // 生成新数据表单
  366. let carouselData = {};
  367. let isPass = this.checkFormItem();
  368. if(!isPass){
  369. return console.log('数据验证不通过');
  370. }
  371. console.log('开始生成新数据表单');
  372. carouselData.sort = this.form.sort.val;
  373. carouselData.type = this.form.type.val;
  374. carouselData.value = this.form.value.val;
  375. carouselData.fileId = this.form.fileData.val;
  376. carouselData.state = this.form.state.val;
  377. // 生成新数据表单完毕
  378. console.log('生成新数据表单完毕');
  379. this.carouselPopLoading = true;
  380. let [err,res] = await handle(this.$axios.put(apiMap.baseAddCarousel.path,carouselData));
  381. this.carouselPopLoading = false;
  382. if(err){
  383. console.log(err);
  384. return this.$message.error('新增轮播图失败');
  385. }
  386. this.$message.success('新增轮播成功');
  387. this.carouselPopShow = false;
  388. await this.getCarouselList();
  389. },
  390. async updateCarouselExecute(){
  391. let carouselData = {};
  392. let isPass = this.checkFormItem();
  393. if(!isPass){
  394. return console.log('数据验证不通过');
  395. }
  396. // 获取更新项
  397. console.log(`获取更新项`);
  398. let updateItems = {};
  399. console.log(this.carouselData);
  400. let carouselId = this.carouselData.id;
  401. if(this.form.sort.val != toNumber(this.carouselData.sort)){
  402. updateItems.sort = this.form.sort.val;
  403. }
  404. if(this.form.type.val != toNumber(this.carouselData.type)){
  405. updateItems.type = this.form.type.val;
  406. }
  407. if(this.form.value.val != this.carouselData.value){
  408. updateItems.value = this.form.value.val;
  409. }
  410. if(toNumber(this.form.fileData.val) != this.carouselData.fileId){
  411. updateItems.fileId = this.form.fileData.val;
  412. }
  413. if(this.form.state.val != this.carouselData.state){
  414. updateItems.state = this.form.state.val;
  415. }
  416. if(isEmpty(updateItems)){
  417. return this.$message.warn('未修改任何数据');
  418. }
  419. console.log(`更新轮播数据,更新数量: ${Object.keys(updateItems).length} 更新字段: [${Object.keys(updateItems).join(',')}]`);
  420. this.carouselPopLoading = true;
  421. let [err,res] = await handle(this.$axios.post(apiMap.baseUpdateCarousel.path,{
  422. carouselId,
  423. updateItems
  424. }));
  425. this.carouselPopLoading = false;
  426. if(err){
  427. console.log(err);
  428. return this.$message.error('更新轮播图失败');
  429. }
  430. let result = res.data;
  431. if (result.code === rCode.OK){
  432. this.$message.success('更新轮播成功');
  433. this.carouselPopShow = false;
  434. await this.getCarouselList();
  435. }else{
  436. this.$message.error(`更新轮播失败,${result.msg}`);
  437. }
  438. },
  439. getCarouselTypeText(type){
  440. type = toNumber(type);
  441. let typeText = '';
  442. if(type === dbField_esm.db_base.carouselType.production){
  443. typeText = '产品';
  444. }else if(type === dbField_esm.db_base.carouselType.news){
  445. typeText = '文章';
  446. }else if(type === dbField_esm.db_base.carouselType.href){
  447. typeText = '直接链接';
  448. }else{
  449. typeText = '暂未支持类型';
  450. }
  451. return typeText
  452. },
  453. getCarouselStateText(state){
  454. // state = toNumber(state);
  455. let typeText = '';
  456. if(state === dbField_esm.db_base.carouselState.enable){
  457. typeText = '启用';
  458. }else if(state === dbField_esm.db_base.carouselState.disable){
  459. typeText = '禁用';
  460. }else{
  461. typeText = '未知状态';
  462. }
  463. return typeText
  464. },
  465. cancelPop(){
  466. this.imageSelectVisible = false;
  467. },
  468. okHandle(fileItem){
  469. console.log('文件列表');
  470. console.log(fileItem);
  471. this.cancelPop();
  472. this.$nextTick(()=>{
  473. this.form.fileData.val = fileItem.fileId;
  474. this.form.fileData.state = 1;
  475. this.form.fileData.msg = '';
  476. this.form.fileData.showText = fileItem.filePath;
  477. })
  478. },
  479. onProductSearchHandle(e){
  480. console.log(`onProductSearchHandle ${e}`);
  481. console.log(e);
  482. console.log(this.productSearch.type.val);
  483. },
  484. onSelectedItemHandle(item){
  485. console.log(`selected item ${item}`);
  486. console.log(item);
  487. this.form.value.val = item.id;
  488. this.form.value.showText = item.showText;
  489. this.form.value.msg = '';
  490. },
  491. onTypeChangeHandle(e){
  492. console.log(`type change ${e}`);
  493. // 清除其他值
  494. this.form.value.val = '';
  495. this.form.value.msg = '';
  496. this.form.value.showText = '';
  497. },
  498. onNewsSearchHandle(e){
  499. console.log(`onProductSearchHandle ${e}`);
  500. console.log(e);
  501. console.log(this.productSearch.type.val);
  502. },
  503. onClickEditHandle(item){
  504. console.log(`点击编辑轮播图`);
  505. console.log(item);
  506. if(!item || !item.id){
  507. return this.$message.warn('轮播数据获取异常,已经取消编辑');
  508. }
  509. this.initCarouseForm();
  510. this.isEditCarousel = true;
  511. this.carouselData = item;
  512. this.carouselPopShow = true;
  513. this.carouselPopLoading = true;
  514. this.form.sort.val = toNumber(item.sort);
  515. this.form.sort.init = toNumber(item.sort);
  516. this.form.type.val = toNumber(item.type);
  517. this.form.type.init = toNumber(item.type);
  518. this.form.value.val = item.value;
  519. this.form.value.init = item.value;
  520. this.form.value.showText = item.valueShowText;
  521. this.form.value.oldShowText = item.oldShowText;
  522. this.form.fileData.val = item.fileId;
  523. this.form.fileData.init = item.fileId;
  524. this.form.fileData.showText = item.filePath;
  525. this.form.fileData.oldShowText = item.filePath;
  526. this.form.state.val = item.state;
  527. this.carouselPopLoading = false;
  528. }
  529. },
  530. })
  531. </script>
  532. <template>
  533. <div class="w-full p-2">
  534. <rounded-title>轮播图管理</rounded-title>
  535. <div class="mt-2 rounded bg-white p-2">
  536. <!-- 轮播图list , 左侧轮播图片, 右侧 轮播信息 -->
  537. <div class="mt-2 rounded bg-white p-2">
  538. <div class="py-1 border-b border-cyan-300 flex justify-between">
  539. 点击下方快进行管理轮播图数据,一次性不要添加过多轮播图
  540. <div class="px-2 flex">
  541. <!-- 新增按钮-->
  542. <a-button type="primary" class="ant-icon-btn mr-2" icon="plus" @click="openAddCarouselModal" :loading="loading"></a-button>
  543. <!-- 刷新按钮-->
  544. <a-button type="primary" class="ant-icon-btn " icon="reload" @click="getCarouselList" :loading="loading"></a-button>
  545. </div>
  546. </div>
  547. <div class="w-full h-auto transition">
  548. <div v-show="loading" class="w-full h-64 flex justify-center items-center ">
  549. <a-spin size="large" />
  550. </div>
  551. <div
  552. v-for="(item,index) in carouselList"
  553. :key="'carouse-'+index"
  554. class="mt-2 rounded border flex h-72 overflow-hidden"
  555. >
  556. <div class="media w-1/2 h-full">
  557. <image-viewer :src="item.filePath"></image-viewer>
  558. </div>
  559. <div class="w-1/2 h-full box-border pl-2">
  560. <div class="w-full py-2 border-bottom border-gray-400">
  561. 排序: {{item.sort}}
  562. </div>
  563. <div class="w-full py-2 border-bottom border-gray-400">
  564. {{getCarouselTypeText(item.type)}}: {{item.valueShowText}}
  565. </div>
  566. <div class="w-full py-2 border-bottom border-gray-400">
  567. 状态: {{getCarouselStateText(item.state)}}
  568. </div>
  569. <a-button @click="onClickEditHandle(item)">编辑</a-button>
  570. </div>
  571. </div>
  572. </div>
  573. </div>
  574. </div>
  575. <pop :show="carouselPopShow" :loading="carouselPopLoading">
  576. <pop-card>
  577. <template slot="header" class="w-full">
  578. {{isEditCarousel ? '编辑轮播图' : '新增轮播图'}}
  579. </template>
  580. <template slot="close-group">
  581. <a-button icon="close" @click="carouselPopShow = false"></a-button>
  582. </template>
  583. <div class="w-full">
  584. <input-row :msg="form.sort.msg"
  585. label="排序">
  586. <a-input-number v-model="form.sort.val"
  587. @focus="form.sort.msg=''"
  588. :min="0"
  589. @blur="checkFormItem('sort')"
  590. />
  591. </input-row>
  592. <input-row :msg="form.state.msg"
  593. label="状态">
  594. <a-radio-group v-model="form.state.val">
  595. <a-radio-button v-for="opt in form.state.options"
  596. :key="'cState'+opt.value"
  597. :value="opt.value">
  598. {{ opt.label }}
  599. </a-radio-button>
  600. </a-radio-group>
  601. </input-row>
  602. <!-- 轮播类型选择 -->
  603. <input-row :msg="form.type.msg"
  604. label="轮播类型">
  605. <a-radio-group v-model="form.type.val" @change="onTypeChangeHandle">
  606. <a-radio-button v-for="opt in form.type.options"
  607. :key="'cType'+opt.value"
  608. :value="opt.value">
  609. {{ opt.label }}
  610. </a-radio-button>
  611. </a-radio-group>
  612. </input-row>
  613. <!-- 轮播具体值 -->
  614. <!-- 链接-->
  615. <input-row
  616. v-show="form.type.val === dbField_esm.db_base.carouselType.href"
  617. :msg="form.value.msg"
  618. label="输入链接">
  619. <a-input v-model="form.value.val"
  620. placeholder="输入要指向的链接地址"
  621. @focus="form.value.msg=''"
  622. @blur="checkFormItem('value', null,'href')"
  623. />
  624. </input-row>
  625. <!-- 产品选择-->
  626. <input-row
  627. v-show="form.type.val === dbField_esm.db_base.carouselType.production"
  628. :msg="form.value.msg"
  629. label="选择产品">
  630. {{ form.value.showText }}
  631. <a-popover v-model="productSelectVisible" title="选择产品" trigger="click">
  632. <div slot="content" class="searchBox" >
  633. <search-box
  634. class="h-72"
  635. :loadDataApi="getProductSearch"
  636. :limit="limit"
  637. search-placeholder="请输入产品名称关键字"
  638. loadTip="正在搜索产品中..."
  639. @onSelectedItem="onSelectedItemHandle"
  640. >
  641. <div class="w-full" slot="otherSearchItem">
  642. <a-radio-group v-model="productSearch.type.val"
  643. @change="onProductSearchHandle">
  644. <a-radio-button v-for="opt in productSearch.type.options"
  645. :key="'cType'+opt.key"
  646. :value="opt.key">
  647. {{ opt.text }}
  648. </a-radio-button>
  649. </a-radio-group>
  650. </div>
  651. </search-box>
  652. </div>
  653. <a-button type="primary" >
  654. 选择产品
  655. </a-button>
  656. </a-popover>
  657. </input-row>
  658. <!-- 新闻选择-->
  659. <input-row
  660. v-show="form.type.val === dbField_esm.db_base.carouselType.news"
  661. :msg="form.value.msg"
  662. label="文章选择">
  663. {{ form.value.showText }}
  664. <a-popover v-model="newsSelectVisible" title="选择你需要的文章" trigger="click">
  665. <div slot="content" class="searchBox" >
  666. <search-box
  667. class="h-72"
  668. :loadDataApi="getNewsSearch"
  669. :limit="limit"
  670. search-placeholder="请输入产品名称关键字"
  671. loadTip="正在搜索产品中..."
  672. ref="productSearch"
  673. @onSelectedItem="onSelectedItemHandle"
  674. >
  675. <div class="w-full" slot="otherSearchItem">
  676. <a-radio-group v-model="newsSearch.type.val"
  677. @change="onNewsSearchHandle">
  678. <a-radio-button v-for="opt in newsSearch.type.options"
  679. :key="'cType'+opt.key"
  680. :value="opt.key">
  681. {{ opt.text }}
  682. </a-radio-button>
  683. </a-radio-group>
  684. </div>
  685. </search-box>
  686. </div>
  687. <a-button type="primary">
  688. 选择文章
  689. </a-button>
  690. </a-popover>
  691. </input-row>
  692. <!-- 选择图片 -->
  693. <input-row label="轮播图片"
  694. :msg="form.fileData.msg">
  695. <a-popover v-model="imageSelectVisible"
  696. class="w-full"
  697. trigger="click">
  698. <image-table slot="content"
  699. class="w-full h-full"
  700. @cancel="imageSelectVisible = false"
  701. @ok="okHandle"></image-table>
  702. <div class="w-full h-60 rounded relative">
  703. <image-viewer class="" :src="form.fileData.showText"></image-viewer>
  704. <div class="absolute w-full h-full left-0 top-0
  705. justify-center text-white bg-gray-400
  706. items-center text-2xl flex opacity-0 hover:opacity-70">
  707. 点击选择图片
  708. </div>
  709. </div>
  710. </a-popover>
  711. </input-row>
  712. </div>
  713. <template class="w-full" slot="footer">
  714. <a-button @click="onPopOkClickHandle">{{isEditCarousel? '保存': '新增'}}</a-button>
  715. </template>
  716. </pop-card>
  717. </pop>
  718. </div>
  719. </template>
  720. <style scoped>
  721. .searchBox{
  722. width: 420px;
  723. height: 520px;
  724. }
  725. </style>