videoMaterialMixin.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. /**
  2. * 新增修改完成调用 modalFormOk方法 编辑弹框组件ref定义为modalForm
  3. * 高级查询按钮调用 superQuery方法 高级查询组件ref定义为superQueryModal
  4. * data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除
  5. */
  6. import {filterObj} from '@/utils/util';
  7. import moment from 'moment'
  8. import {deleteAction, getAction, downFile} from '@/api/manage'
  9. import Vue from 'vue'
  10. import {ACCESS_TOKEN} from "@/store/mutation-types"
  11. import { transformTozTreeFormat } from '@/utils/util.js'
  12. import {mapGetters} from 'vuex';
  13. export const JeecgListMixin = {
  14. data() {
  15. return {
  16. spinning:true,
  17. //token header
  18. tokenHeader: {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)},
  19. /* 查询条件-请不要在queryParam中声明非字符串值的属性 */
  20. queryParam: {},
  21. /* 数据源 */
  22. dataSource: [],
  23. innerData:[],
  24. /* 分页参数 */
  25. ipagination: {
  26. current: 1,
  27. pageSize: 10,
  28. pageSizeOptions: ['8', '16', '32'],
  29. showTotal: (total, range) => {
  30. return range[0] + "-" + range[1] + " 共" + total + "条"
  31. },
  32. showQuickJumper: true,
  33. // showSizeChanger: true,
  34. total: 0
  35. },
  36. /* 排序参数 */
  37. isorter: {
  38. column: 'createTime',
  39. order: 'desc',
  40. },
  41. /* 筛选参数 */
  42. filters: {},
  43. /* table加载状态 */
  44. loading: false,
  45. /* table选中keys*/
  46. selectedRowKeys: [],
  47. /* table选中records*/
  48. selectionRows: [],
  49. /* 查询折叠 */
  50. toggleSearchStatus: false,
  51. /* 高级查询条件生效状态 */
  52. superQueryFlag: false,
  53. /* 高级查询条件 */
  54. superQueryParams: ""
  55. }
  56. },
  57. mounted() {
  58. if(this.startList){
  59. }else{
  60. this.loadData();
  61. }
  62. //初始化字典配置 在自己页面定义
  63. this.initDictConfig();
  64. },
  65. methods: {
  66. // 二级树
  67. expand(expanded,record){
  68. if(this.url.listTwo){
  69. var param = {}
  70. param.field = this.getQueryField();
  71. param.pageNo = this.ipagination.current;
  72. param.pageSize = this.ipagination.pageSize;
  73. param.parentId = record.id
  74. if(expanded){
  75. getAction(this.url.listTwo, filterObj(param)).then((res) => {
  76. if (res.success) {
  77. record.innerData=res.result.records.map((item,index)=>{
  78. return {
  79. ...item,
  80. key:index
  81. }
  82. })
  83. // console.log(record.innerData)
  84. record.innerData = transformTozTreeFormat( record.innerData)
  85. }
  86. if (res.code === 510) {
  87. this.$message.warning(res.message)
  88. }
  89. this.loading = false;
  90. })
  91. }else{
  92. record.innerData = []
  93. }
  94. }
  95. },
  96. ...mapGetters(['nickname', 'avatar', 'userInfo']),
  97. async loadData(arg) {
  98. this.cancel()
  99. this.spinning= true
  100. this.dataSource = []
  101. if (!this.url.list) {
  102. this.$message.error("请设置url.list属性!")
  103. return
  104. }
  105. //加载数据 若传入参数1则加载第一页的内容
  106. if (arg === 1) {
  107. this.ipagination.current = 1;
  108. }
  109. var params = this.getQueryParams();//查询条件
  110. if(params.createTime&&params.createTime.length>0){
  111. // params.createTime = moment(params.createTime).format('YYYY-MM-DD')
  112. params.startDate = moment(params.createTime[0]).format('YYYY-MM-DD')
  113. params.endDate = moment(params.createTime[1]).format('YYYY-MM-DD')
  114. params.createTime = null
  115. }
  116. if(params.stateDate){
  117. params.stateDate = moment(params.stateDate).format('YYYY-MM-DD')
  118. }
  119. if(params.createTimeDate&&params.createTimeDate.length>0){
  120. // params.createTime = moment(params.createTime).format('YYYY-MM-DD')
  121. params.startTime = moment(params.createTimeDate[0]).format('YYYY-MM-DD')
  122. params.endTime = moment(params.createTimeDate[1]).format('YYYY-MM-DD')
  123. params.createTimeDate = null
  124. }
  125. // if(params.endDate){
  126. // params.endDate = moment(params.endDate).format('YYYY-MM-DD')
  127. // }
  128. if(params.videoStatus == 0){
  129. params.syncKuaishou = null
  130. params.syncBytedance = null
  131. }else if(params.videoStatus == 1){
  132. params.syncKuaishou = 1
  133. params.syncBytedance = 1
  134. }else if(params.videoStatus == '2'){
  135. params.syncKuaishou = 1
  136. params.syncBytedance = null
  137. }else if(params.videoStatus == 3){
  138. params.syncKuaishou = null
  139. params.syncBytedance = 1
  140. }else if(params.videoStatus == 4){
  141. params.syncKuaishou = 2
  142. params.syncBytedance = null
  143. }else if(params.videoStatus == 5){
  144. params.syncKuaishou = null
  145. params.syncBytedance = 2
  146. }else if(params.videoStatus == 6){
  147. params.syncKuaishou = 2
  148. params.syncBytedance = 2
  149. }else{
  150. params.syncKuaishou = null
  151. params.syncBytedance = null
  152. }
  153. this.loading = true;
  154. params.userId = this.userInfo().id
  155. await getAction(this.url.list, params).then((res) => {
  156. if (res.success) {
  157. this.loading = false;
  158. if(res.result){
  159. if(res.result.records){
  160. this.dataSource = res.result.records.map(item=>{
  161. return {
  162. ...item,
  163. innerData:[],
  164. showVideo:false
  165. }
  166. })
  167. this.ipagination.total = res.result.total;
  168. }else if(res.result.list){
  169. this.dataSource = res.result.list.map(item=>{
  170. return {
  171. ...item,
  172. innerData:[],
  173. showVideo:false
  174. }
  175. })
  176. this.ipagination.total = res.result.total;
  177. }else{
  178. this.dataSource = res.result.map(item=>{
  179. return {
  180. ...item,
  181. innerData:[],
  182. showVideo:false
  183. }
  184. })
  185. // this.ipagination = null;
  186. this.ipagination.pageSize=res.result.length
  187. }
  188. }else if(res.data){
  189. if(res.data.list){
  190. this.dataSource = res.data.list.map(item=>{
  191. return {
  192. ...item,
  193. innerData:[],
  194. showVideo:false
  195. }
  196. })
  197. this.ipagination.total = res.data.total;
  198. }
  199. }
  200. this.spinning= false
  201. }
  202. if (res.code === 510) {
  203. this.$message.warning(res.message)
  204. }
  205. this.loading = false;
  206. this.spinning= false
  207. })
  208. },
  209. initDictConfig() {
  210. // console.log("--这是一个假的方法!")
  211. },
  212. handleSuperQuery(arg) {
  213. //高级查询方法
  214. if (!arg) {
  215. this.superQueryParams = ''
  216. this.superQueryFlag = false
  217. } else {
  218. this.superQueryFlag = true
  219. this.superQueryParams = JSON.stringify(arg)
  220. }
  221. this.loadData()
  222. },
  223. editDate(value) {
  224. let date = new Date(value)
  225. let y = date.getFullYear()
  226. let MM = date.getMonth() + 1
  227. MM = MM < 10 ? '0' + MM : MM
  228. let d = date.getDate()
  229. d = d < 10 ? '0' + d : d
  230. return y + '-' + MM + '-' + d
  231. },
  232. getQueryParams() {
  233. //获取查询条件
  234. let sqp = {}
  235. if (this.superQueryParams) {
  236. sqp['superQueryParams'] = encodeURI(this.superQueryParams)
  237. }
  238. // console.log(this.queryParam)
  239. var param = {...this.queryParam,...this.isorter, ...this.filters}
  240. param.pageNo = this.ipagination.current;
  241. param.pageSize = this.ipagination.pageSize;
  242. return param
  243. },
  244. getQueryField() {
  245. //TODO 字段权限控制
  246. var str = "id,";
  247. this.columns.forEach(function (value) {
  248. str += "," + value.dataIndex;
  249. });
  250. return str;
  251. },
  252. onSelectChange(selectedRowKeys, selectionRows) {
  253. this.selectedRowKeys = selectedRowKeys;
  254. this.selectionRows = selectionRows;
  255. },
  256. onClearSelected() {
  257. this.selectedRowKeys = [];
  258. this.selectionRows = [];
  259. },
  260. searchQuery() {
  261. this.loadData(1);
  262. },
  263. superQuery() {
  264. this.$refs.superQueryModal.show();
  265. },
  266. searchReset() {
  267. this.queryParam = {}
  268. this.loadData(1);
  269. },
  270. batchDel: function () {
  271. if (!this.url.deleteBatch) {
  272. this.$message.error("请设置url.deleteBatch属性!")
  273. return
  274. }
  275. if (this.selectedRowKeys.length <= 0) {
  276. this.$message.warning('请选择一条记录!');
  277. return;
  278. } else {
  279. var ids = "";
  280. for (var a = 0; a < this.selectedRowKeys.length; a++) {
  281. ids += this.selectedRowKeys[a] + ",";
  282. }
  283. var that = this;
  284. this.$confirm({
  285. title: "确认删除",
  286. content: "是否删除选中数据?",
  287. onOk: function () {
  288. deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
  289. if (res.success) {
  290. that.$message.success(res.message);
  291. that.loadData();
  292. that.onClearSelected();
  293. } else {
  294. that.$message.warning(res.message);
  295. }
  296. });
  297. }
  298. });
  299. }
  300. },
  301. handleDelete: function (id) {
  302. if (!this.url.delete) {
  303. this.$message.error("请设置url.delete属性!")
  304. return
  305. }
  306. var that = this;
  307. deleteAction(that.url.delete, {id: id}).then((res) => {
  308. if (res.success) {
  309. that.$message.success(res.message);
  310. that.loadData();
  311. } else {
  312. that.$message.warning(res.message);
  313. }
  314. });
  315. },
  316. handleEdit: function (record,sign) {
  317. // console.log(record,sign)
  318. this.$refs.modalForm.edit(record,sign);
  319. this.$refs.modalForm.title = "编辑";
  320. this.$refs.modalForm.disableSubmit = false;
  321. if(sign == 'preview'){
  322. this.$refs.modalForm.title = "预览";
  323. }
  324. },
  325. handleImagePreview: function (record) {
  326. this.$refs.modalForm.imagePreview(record);
  327. this.$refs.modalForm.title = "预览";
  328. this.$refs.modalForm.disableSubmit = false;
  329. },
  330. handleAdd: function (sign) {
  331. this.$refs.modalForm.add(sign);
  332. this.$refs.modalForm.title = "新增";
  333. this.$refs.modalForm.disableSubmit = false;
  334. },
  335. handleOpen: function () {
  336. this.$refs.userForm.open();
  337. this.$refs.userForm.title = "选择";
  338. this.$refs.userForm.disableSubmit = false;
  339. },
  340. handleTableChange(pagination, filters, sorter) {
  341. //分页、排序、筛选变化时触发
  342. //TODO 筛选
  343. if (Object.keys(sorter).length > 0) {
  344. this.isorter.column = sorter.field;
  345. this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
  346. }
  347. this.ipagination = pagination;
  348. this.loadData();
  349. },
  350. handleToggleSearch() {
  351. this.toggleSearchStatus = !this.toggleSearchStatus;
  352. },
  353. modalFormOk() {
  354. // 新增/修改 成功时,重载列表
  355. this.loadData(this.ipagination.current);
  356. },
  357. handleDetail: function (record) {
  358. this.$nextTick(()=>{
  359. this.$refs.modalForm.edit(record);
  360. this.$refs.modalForm.title = "详情";
  361. this.$refs.modalForm.disableSubmit = true;
  362. })
  363. },
  364. /* 导出 */
  365. handleExportXls2() {
  366. let paramsStr = encodeURI(JSON.stringify(this.getQueryParams()));
  367. let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`;
  368. window.location.href = url;
  369. },
  370. handleExportXls(fileName) {
  371. if (!fileName || typeof fileName != "string") {
  372. fileName = "导出文件"
  373. }
  374. let param = {...this.queryParam};
  375. if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
  376. param['selections'] = this.selectedRowKeys.join(",")
  377. }
  378. // console.log("导出参数", param)
  379. downFile(this.url.exportXlsUrl, param).then((data) => {
  380. if (!data) {
  381. this.$message.warning("文件下载失败")
  382. return
  383. }
  384. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  385. window.navigator.msSaveBlob(new Blob([data]), fileName + '.xls')
  386. } else {
  387. let url = window.URL.createObjectURL(new Blob([data]))
  388. let link = document.createElement('a')
  389. link.style.display = 'none'
  390. link.href = url
  391. link.setAttribute('download', fileName + '.xls')
  392. document.body.appendChild(link)
  393. link.click()
  394. document.body.removeChild(link); //下载完成移除元素
  395. window.URL.revokeObjectURL(url); //释放掉blob对象
  396. }
  397. })
  398. },
  399. /* 导入 */
  400. handleImportExcel(info) {
  401. if (info.file.status !== 'uploading') {
  402. // console.log(info.file, info.fileList);
  403. }
  404. if (info.file.status === 'done') {
  405. if (info.file.response.success) {
  406. this.$message.success(`${info.file.name} 文件上传成功`);
  407. this.loadData();
  408. } else {
  409. this.$message.error(`${info.file.name} ${info.file.response.message}.`);
  410. }
  411. } else if (info.file.status === 'error') {
  412. this.$message.error(`文件上传失败: ${info.file.msg} `);
  413. }
  414. },
  415. /* 图片预览 */
  416. getImgView(text) {
  417. if (text && text.indexOf(",") > 0) {
  418. text = text.substring(0, text.indexOf(","))
  419. }
  420. return window._CONFIG['imgDomainURL'] + "/" + text
  421. },
  422. /* 文件下载 */
  423. uploadFile(text) {
  424. if (!text) {
  425. this.$message.warning("未知的文件")
  426. return;
  427. }
  428. if (text.indexOf(",") > 0) {
  429. text = text.substring(0, text.indexOf(","))
  430. }
  431. window.open(window._CONFIG['domianURL'] + "/sys/common/download/" + text);
  432. },
  433. }
  434. }