user_workfile_list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div>
  3. <div class="count-list">
  4. <div class="count-item">全部:{{ total || 0 }}</div>
  5. </div>
  6. <div>
  7. <el-table :data="workfileData" border style="width: 100%" v-loading="loading">
  8. <el-table-column
  9. prop=""
  10. label="资源简介">
  11. <template slot-scope="scope">
  12. <span class="lblue point">
  13. <span @click="downloadWorkFile(scope.row.id)">{{ scope.row.file_name }}</span>
  14. </span>
  15. </template>
  16. </el-table-column>
  17. <el-table-column
  18. prop=""
  19. label="资源大小">
  20. <template slot-scope="scope">
  21. <!-- <span class="lblue point">-->
  22. <span>
  23. <span>{{ scope.row.file_size_name }}</span>
  24. </span>
  25. </template>
  26. </el-table-column>
  27. <el-table-column
  28. prop=""
  29. label="作品名称">
  30. <template slot-scope="scope">
  31. <!-- <span class="lblue point">-->
  32. <span>
  33. <span>{{ scope.row.work_name }}</span>
  34. </span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column
  38. prop=""
  39. label="作者">
  40. <template slot-scope="scope">
  41. <span class="lblue point">
  42. <a onclick="javascript:void(0)" v-if="scope.row.nickname == '-'">{{ scope.row.nickname }}</a>
  43. <a target="_blank" :href="scope.row.host+'/wo/'+scope.row.uid" v-else>{{ scope.row.nickname }}</a>
  44. </span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column prop="pay_time" label="发布时间">
  48. <template slot-scope="scope">
  49. <span>{{ formatDate(scope.row.file_time, 'Y-m-d H:i') }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column prop="pay_time" label="基本数据">
  53. <template slot-scope="scope">
  54. <span>下载:{{ scope.row.download || 0 }}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column prop="pay_time" label="当前状态">
  58. <template slot-scope="scope">
  59. <span v-if="scope.row.status == '0'">待审核</span>
  60. <span v-else-if="scope.row.status == '1'">上架</span>
  61. <span v-else-if="scope.row.status == '2'">下架</span>
  62. <span v-else>--</span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="uid" label="操作">
  66. <template slot-scope="scope">
  67. <el-button type="text" v-if="scope.row.status != '1' " @click="onChange(scope.row.id,1)">上架</el-button>
  68. <el-button type="text" v-if="scope.row.status != '2' " @click="onChange(scope.row.id,2)">下架</el-button>
  69. <el-button type="text" @click="onDelete(scope.row.id)">删除</el-button>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. </div>
  74. <div style="padding-top: 5px">
  75. <el-pagination
  76. class="order-footer"
  77. background
  78. layout="total, prev, pager, next"
  79. :page-size="20"
  80. :total="total"
  81. @current-change="handleCurrentChange"
  82. />
  83. </div>
  84. </div>
  85. </template>
  86. <script>
  87. export default {
  88. name: "user_cards_list",
  89. data() {
  90. return {
  91. page: 1,
  92. total: 0,
  93. workfileData: [],
  94. loading:false,
  95. }
  96. },
  97. mounted() {
  98. this.getAuditList();
  99. },
  100. methods: {
  101. async getAuditList() {
  102. const page = this.page;
  103. const data = {
  104. page
  105. };
  106. let res = await this.$post("/api/admin/UserWorks/getWorkFileList", data);
  107. if (res && res.status === 1) {
  108. this.workfileData = res.data.list || [];
  109. this.total = res.data.total * 1;
  110. }
  111. },
  112. onDelete(id) {
  113. this.loading = true;
  114. this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
  115. confirmButtonText: '确定',
  116. cancelButtonText: '取消',
  117. type: 'warning'
  118. }).then(() => {
  119. this.deleteWorkFile(id)
  120. }).catch(() => {
  121. this.$message({
  122. type: 'info',
  123. message: '已取消删除'
  124. });
  125. this.loading = false;
  126. });
  127. },
  128. async deleteWorkFile(id) {
  129. let res = await this.$post("/api/admin/UserWorks/deleteWorkFile", {id: id});
  130. if (res && res.status === 1) {
  131. this.$message({
  132. type: 'success',
  133. message: '删除成功!'
  134. });
  135. this.getAuditList();
  136. this.loading = false;
  137. }
  138. },
  139. async onChange(id, type) {
  140. this.loading = true;
  141. let res = await this.$post("/api/admin/UserWorks/changeWorkFile", {id: id, type: type});
  142. if (res && res.status === 1) {
  143. this.$message({
  144. type: 'success',
  145. message: '操作成功!'
  146. });
  147. this.getAuditList();
  148. this.loading = false;
  149. }
  150. },
  151. async downloadWorkFile(id) {
  152. let url = window.location.host + '/api/admin/UserWorks/downloadWorkFile?id=' + id;
  153. window.location.href = "https://" + url;
  154. },
  155. handleCurrentChange(val) {
  156. this.page = val;
  157. this.getAuditList();
  158. },
  159. formatDate(time, format = '') {
  160. if (time === "0") {
  161. return "--";
  162. }
  163. let now = new Date(time * 1000);
  164. let year = now.getFullYear();
  165. let month = now.getMonth() + 1;
  166. let date = now.getDate();
  167. let hour = now.getHours();
  168. let minute = now.getMinutes();
  169. let second = now.getSeconds();
  170. if (hour < 10) {
  171. hour = "0" + hour;
  172. }
  173. if (minute < 10) {
  174. minute = "0" + minute;
  175. }
  176. if (second < 10) {
  177. second = "0" + second;
  178. }
  179. return (format == '' ?
  180. year +
  181. "-" +
  182. month +
  183. "-" +
  184. date +
  185. " " +
  186. hour +
  187. ":" +
  188. minute +
  189. ":" +
  190. second
  191. :
  192. year +
  193. "-" +
  194. month +
  195. "-" +
  196. date +
  197. " " +
  198. hour +
  199. ":" +
  200. minute
  201. );
  202. },
  203. }
  204. }
  205. </script>
  206. <style scoped>
  207. .count-list {
  208. padding-bottom: 10px;
  209. display: flex;
  210. align-items: center;
  211. }
  212. </style>