production.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot="menuLeft">
  22. <el-button type="danger"
  23. size="small"
  24. icon="el-icon-delete"
  25. plain
  26. v-if="permission.production_delete"
  27. @click="handleDelete">删 除
  28. </el-button>
  29. </template>
  30. <template slot="userInfo" slot-scope="scope" v-if="scope.row.loginWebVO">
  31. <div style="display: flex;">
  32. <div style="display: flex;justify-content: center;align-items: center;">
  33. <el-avatar size="large" :src="scope.row.loginWebVO.avatar"></el-avatar>
  34. </div>
  35. <div style="padding: 10px;">
  36. <div >昵称:{{scope.row.loginWebVO.nickName}}</div>
  37. <div>手机:{{scope.row.loginWebVO.phone}}</div>
  38. </div>
  39. </div>
  40. </template>
  41. <template slot="rank" slot-scope="scope">
  42. <el-tag effect="dark">
  43. {{scope.row.loginWebVO.rank}}
  44. </el-tag>
  45. </template>
  46. <template slot="urlsType" slot-scope="scope">
  47. <div v-if="scope.row.urlsType==0">图文</div>
  48. <div v-if="scope.row.urlsType==1">视频</div>
  49. </template>
  50. <template slot="urls" slot-scope="scope">
  51. <el-image v-if="scope.row.urlsType==0" :preview-src-list="[scope.row.urls]" style="width: 50px;height: 50px;" :src="scope.row.urls"></el-image>
  52. <video style="width: 50px;height: 50px;" :src="scope.row.urls" v-if="scope.row.urlsType==1" :controls="false" :autoplay="true"></video>
  53. </template>
  54. </avue-crud>
  55. </basic-container>
  56. </template>
  57. <script>
  58. import {getList, getDetail, add, update, remove} from "@/api/production/production";
  59. import {mapGetters} from "vuex";
  60. export default {
  61. props:{
  62. activityId:String
  63. },
  64. data() {
  65. return {
  66. maskshow:false,
  67. urls:[],
  68. form: {},
  69. query: {},
  70. loading: true,
  71. page: {
  72. pageSize: 10,
  73. currentPage: 1,
  74. total: 0
  75. },
  76. selectionList: [],
  77. option: {
  78. // menu:false,
  79. memuLeft:true,
  80. height:'auto',
  81. calcHeight: 30,
  82. tip: false,
  83. searchShow: true,
  84. searchMenuSpan: 6,
  85. border: true,
  86. index: true,
  87. viewBtn: true,
  88. delBtn:true,
  89. selection: true,
  90. dialogClickModal: false,
  91. column: [
  92. {
  93. hide:true,
  94. label: "用户id",
  95. prop: "userId",
  96. rules: [{
  97. required: true,
  98. message: "请输入用户id",
  99. trigger: "blur"
  100. }]
  101. },
  102. {
  103. label:"用户信息",
  104. slot:true,
  105. width: 200,
  106. prop:"userInfo"
  107. },
  108. {
  109. label: "排名",
  110. prop: "rank",
  111. slot:true
  112. },
  113. {
  114. label: "活动id",
  115. prop: "activityId",
  116. hide:true,
  117. rules: [{
  118. required: true,
  119. message: "请输入活动id",
  120. trigger: "blur"
  121. }]
  122. },
  123. {
  124. label: "参赛名字",
  125. prop: "personName",
  126. rules: [{
  127. required: true,
  128. message: "请输入参赛名字",
  129. trigger: "blur"
  130. }]
  131. },
  132. {
  133. label: "作品名称",
  134. prop: "title",
  135. rules: [{
  136. required: true,
  137. message: "请输入作品名称",
  138. trigger: "blur"
  139. }]
  140. },
  141. {
  142. label: "介绍",
  143. prop: "introduce",
  144. overHidden: true,
  145. rules: [{
  146. required: true,
  147. message: "请输入个人介绍/个人宣言",
  148. trigger: "blur"
  149. }]
  150. },
  151. {
  152. label: "基本信息",
  153. prop: "personType",
  154. rules: [{
  155. required: true,
  156. message: "请输入基本信息",
  157. trigger: "blur"
  158. }]
  159. },
  160. {
  161. label: "作品资源",
  162. slot:true,
  163. prop: "urls",
  164. rules: [{
  165. required: true,
  166. message: "请输入作品资源",
  167. trigger: "blur"
  168. }]
  169. },
  170. {
  171. label: "资源类型",
  172. prop: "urlsType",
  173. slot:true
  174. },
  175. {
  176. label: "作品热力值",
  177. prop: "hotValue",
  178. rules: [{
  179. required: true,
  180. message: "请输入作品热力值",
  181. trigger: "blur"
  182. }]
  183. },
  184. {
  185. label: "作品封面",
  186. hide:true,
  187. prop: "cover",
  188. rules: [{
  189. required: true,
  190. message: "请输入作品封面",
  191. trigger: "blur"
  192. }]
  193. },
  194. {
  195. label: "总浏览人数",
  196. prop: "visitTotal",
  197. rules: [{
  198. required: true,
  199. message: "请输入总浏览人数",
  200. trigger: "blur"
  201. }]
  202. },
  203. ]
  204. },
  205. data: []
  206. };
  207. },
  208. computed: {
  209. ...mapGetters(["permission"]),
  210. permissionList() {
  211. return {
  212. addBtn: this.vaildData(this.permission.production_add, false),
  213. viewBtn: this.vaildData(this.permission.production_view, false),
  214. delBtn: this.vaildData(this.permission.production_delete, false),
  215. editBtn: this.vaildData(this.permission.production_edit, false)
  216. };
  217. },
  218. ids() {
  219. let ids = [];
  220. this.selectionList.forEach(ele => {
  221. ids.push(ele.id);
  222. });
  223. return ids.join(",");
  224. }
  225. },
  226. methods: {
  227. rowSave(row, done, loading) {
  228. add(row).then(() => {
  229. this.onLoad(this.page);
  230. this.$message({
  231. type: "success",
  232. message: "操作成功!"
  233. });
  234. done();
  235. }, error => {
  236. loading();
  237. window.console.log(error);
  238. });
  239. },
  240. rowUpdate(row, index, done, loading) {
  241. update(row).then(() => {
  242. this.onLoad(this.page);
  243. this.$message({
  244. type: "success",
  245. message: "操作成功!"
  246. });
  247. done();
  248. }, error => {
  249. loading();
  250. console.log(error);
  251. });
  252. },
  253. rowDel(row) {
  254. this.$confirm("确定将选择数据删除?", {
  255. confirmButtonText: "确定",
  256. cancelButtonText: "取消",
  257. type: "warning"
  258. })
  259. .then(() => {
  260. return remove(row.id);
  261. })
  262. .then(() => {
  263. this.onLoad(this.page);
  264. this.$message({
  265. type: "success",
  266. message: "操作成功!"
  267. });
  268. });
  269. },
  270. handleDelete() {
  271. if (this.selectionList.length === 0) {
  272. this.$message.warning("请选择至少一条数据");
  273. return;
  274. }
  275. this.$confirm("确定将选择数据删除?", {
  276. confirmButtonText: "确定",
  277. cancelButtonText: "取消",
  278. type: "warning"
  279. })
  280. .then(() => {
  281. return remove(this.ids);
  282. })
  283. .then(() => {
  284. this.onLoad(this.page);
  285. this.$message({
  286. type: "success",
  287. message: "操作成功!"
  288. });
  289. this.$refs.crud.toggleSelection();
  290. });
  291. },
  292. beforeOpen(done, type) {
  293. if (["edit", "view"].includes(type)) {
  294. getDetail(this.form.id).then(res => {
  295. this.form = res.data.data;
  296. });
  297. }
  298. done();
  299. },
  300. searchReset() {
  301. this.query = {};
  302. this.onLoad(this.page);
  303. },
  304. searchChange(params, done) {
  305. this.query = params;
  306. this.page.currentPage = 1;
  307. this.onLoad(this.page, params);
  308. done();
  309. },
  310. selectionChange(list) {
  311. this.selectionList = list;
  312. },
  313. selectionClear() {
  314. this.selectionList = [];
  315. this.$refs.crud.toggleSelection();
  316. },
  317. currentChange(currentPage){
  318. this.page.currentPage = currentPage;
  319. },
  320. sizeChange(pageSize){
  321. this.page.pageSize = pageSize;
  322. },
  323. refreshChange() {
  324. this.onLoad(this.page, this.query);
  325. },
  326. onLoad(page, params = {}) {
  327. this.loading = true;
  328. if (this.activityId) {
  329. this.query.activityId=this.activityId
  330. }
  331. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  332. const data = res.data.data;
  333. this.page.total = data.total;
  334. this.data = data.records;
  335. this.loading = false;
  336. this.selectionClear();
  337. });
  338. },
  339. viewUrls(urls){
  340. this.maskshow=true
  341. this.urls=urls
  342. }
  343. }
  344. };
  345. </script>
  346. <style scoped>
  347. </style>