zhidaoList.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <div id="zhidaoList">
  3. <el-row>
  4. <el-col :span="24">
  5. <el-col :span="24" class="search">
  6. <!--<el-col :span="5">
  7. <span>筛选条件:</span>
  8. <el-select v-model="search.region" placeholder="请选择">
  9. <el-option label="类型一" value="0"></el-option>
  10. <el-option label="类型二" value="1"></el-option>
  11. </el-select>
  12. </el-col>-->
  13. <span>输入条件:</span>
  14. <el-input clearable v-model="search.name" :placeholder="placeholder" class="input"></el-input>
  15. <!--<el-col :span="7">
  16. <span>时间选择:</span>
  17. <el-date-picker v-model="search.date" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker>
  18. </el-col>-->
  19. <el-button class="btnSearch" @click="toQuery">查询</el-button>
  20. <!-- <el-button class="btnSearch qing" @click="toClear">清空</el-button>-->
  21. </el-col>
  22. <el-col :span="24">
  23. <el-table
  24. v-loading = "pictLoading"
  25. element-loading-text = "数据正在加载中"
  26. element-loading-spinner = "el-icon-loading"
  27. ref="tableData"
  28. :data="tableData"
  29. tooltip-effect="dark"
  30. :default-sort="{ prop: 'date', order: 'descending' }"
  31. style="width: 100%"
  32. @selection-change="handleSelectionChange"
  33. >
  34. <!--<el-table-column type="selection" align="center"> </el-table-column>-->
  35. <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
  36. <el-table-column property="name" label="名称" align="center"></el-table-column>
  37. <el-table-column label="图片" align="center">
  38. <template slot-scope="scope">
  39. <span> <el-image v-if="scope.row.image" :src="scope.row.image" style="height:20px;width:20px "
  40. @click="showImage(scope.row.image)"></el-image></span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column property="link" label="链接" align="center"></el-table-column>
  44. <el-table-column label="操作" align="center" width="300px">
  45. <template slot-scope="scope">
  46. <el-button size="mini" title="修改信息" type="text" class="edit" icon="el-icon-edit"
  47. @click="$router.push({ path: '/zhidao/detail', query: { id: scope.row.id } })"></el-button>
  48. <el-button size="mini" title="删除" type="text" class="delete" icon="el-icon-delete"
  49. @click.prevent="deleteRow(scope.row.id)"></el-button>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. <el-row>
  54. <el-pagination
  55. @size-change="handleSizeChange"
  56. @current-change="handleCurrentChange"
  57. :current-page.sync="currentPage"
  58. :page-sizes="[10, 20, 30, 40]"
  59. :page-size.sync="limit"
  60. background
  61. layout="total, prev, pager, next, jumper"
  62. :total="total"
  63. >
  64. </el-pagination>
  65. </el-row>
  66. </el-col>
  67. </el-col>
  68. </el-row>
  69. <el-dialog
  70. :visible.sync="dialogVisible"
  71. width="30%"
  72. >
  73. <el-image :src="elImage" style="height:100%;width:100% "></el-image>
  74. </el-dialog>
  75. </div>
  76. </template>
  77. <script>
  78. export default {
  79. name: 'zhidaoList',
  80. props: {
  81. tableData: null,
  82. total: null,
  83. },
  84. components: {},
  85. data: () => ({
  86. placeholder: '请输入名称',
  87. search: {},
  88. currentPage: 1,
  89. limit: 10,
  90. dialogVisible: false,
  91. elImage: '',
  92. pictLoading:true,
  93. }),
  94. watch:{
  95. tableData(){
  96. this.pictLoading = false;
  97. }
  98. },
  99. created() {
  100. },
  101. computed: {},
  102. methods: {
  103. handleSelectionChange(val) {
  104. this.multipleSelection = val;
  105. },
  106. deleteRow(id) {
  107. this.$confirm('确定删除吗?', '提示', {
  108. confirmButtonText: '确定',
  109. cancelButtonText: '取消',
  110. type: 'warning'
  111. }).then(() => {
  112. this.$set(this, `currentPage`, 1);
  113. this.$emit('deleteRow', {id: id, skip: 0, limit: this.limit, ...this.search});
  114. }).catch(() => {
  115. this.$message({
  116. type: 'info',
  117. message: '已取消删除'
  118. });
  119. });
  120. },
  121. handleSizeChange(val) {
  122. this.$set(this, `currentPage`, 1);
  123. this.$emit('select', {skip: 0, limit: val, ...this.search});
  124. },
  125. handleCurrentChange(val) {
  126. this.$set(this, `pictLoading`, true);
  127. this.$emit('select', {skip: (val - 1) * this.limit, limit: this.limit, ...this.search});
  128. },
  129. toQuery() {
  130. this.$set(this, `currentPage`, 1);
  131. this.$set(this, `pictLoading`, true);
  132. this.$emit('select', {skip: 0, limit: this.limit, ...this.search});
  133. },
  134. toClear() {
  135. let keys = Object.keys(this.search);
  136. for (const key of keys) {
  137. this.$set(this.search, `${key}`, '');
  138. }
  139. },
  140. showImage(image) {
  141. if(image){
  142. this.$set(this, `elImage`, image);
  143. this.$set(this, `dialogVisible`, true);
  144. }else{
  145. this.$set(this, `dialogVisible`, false);
  146. }
  147. }
  148. },
  149. };
  150. </script>
  151. <style lang="less" scoped>
  152. /deep/ .el-checkbox__input.is-checked .el-checkbox__inner {
  153. background-color: red;
  154. border-color: red;
  155. }
  156. /deep/ .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  157. background-color: red;
  158. border-color: red;
  159. }
  160. /deep/ .el-table th {
  161. background-color: #f5f6fa;
  162. padding: 8px 0;
  163. }
  164. /deep/ .el-table td {
  165. padding: 11px 0;
  166. }
  167. .other {
  168. color: #f36302;
  169. }
  170. .view {
  171. color: #f36302;
  172. }
  173. .edit {
  174. color: #2ccc02;
  175. }
  176. .delete {
  177. color: #e9021d;
  178. }
  179. /deep/ .el-pagination {
  180. padding: 26px 20px;
  181. }
  182. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  183. background-color: red;
  184. }
  185. .input {
  186. width: 150px;
  187. margin-right: 10px;
  188. }
  189. /*/deep/ .el-input__inner {*/
  190. /* height: 35px;*/
  191. /* line-height: 35px;*/
  192. /*}*/
  193. .btnSearch {
  194. width: 80px;
  195. height: 34px;
  196. background: rgba(233, 2, 29, 1);
  197. border-radius: 4px;
  198. padding: 0;
  199. color: #fff;
  200. }
  201. /*.qing {*/
  202. /* background: rgba(185, 185, 185, 1);*/
  203. /*}*/
  204. .top {
  205. height: 50px;
  206. margin: 0 0 10px 0;
  207. }
  208. .search {
  209. background: #ffffff;
  210. width: 97%;
  211. height: 35px;
  212. margin: 20px;
  213. margin-left: 0px;
  214. }
  215. .list {
  216. padding: 0 20px;
  217. }
  218. /deep/ .el-input__suffix {
  219. .el-input__suffix-inner {
  220. border-color: unset;
  221. .el-icon-circle-close:before {
  222. content: "\e79d" !important;
  223. font-size: 20px;
  224. }
  225. }
  226. }
  227. /deep/ .el-icon-edit {
  228. background: url(../../assets/xiugaixinxi.png) center no-repeat;
  229. background-size: cover;
  230. width: 25px;
  231. height: 25px;
  232. }
  233. /deep/ .el-icon-edit:before {
  234. content: "替";
  235. font-size: 16px;
  236. visibility: hidden;
  237. }
  238. /deep/ .el-icon-delete {
  239. background: url(../../assets/shanchu.png) center no-repeat;
  240. background-size: cover;
  241. width: 25px;
  242. height: 25px;
  243. }
  244. /deep/ .el-icon-delete:before {
  245. content: "替";
  246. font-size: 16px;
  247. visibility: hidden;
  248. }
  249. /deep/ .el-table__row .cell .edit:first-child {
  250. margin-right: 10px;
  251. }
  252. /deep/.el-loading-spinner .el-loading-text {
  253. color: #e9021d;
  254. margin: 3px 0;
  255. font-size: 14px;
  256. }
  257. /deep/ .el-icon-loading {
  258. background: url(../../assets/loading.png) center no-repeat;
  259. background-size: cover;
  260. width: 25px;
  261. height: 25px;
  262. }
  263. /deep/ .el-icon-loading:before {
  264. content: "替";
  265. visibility: hidden;
  266. }
  267. </style>