digitalServiceList.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div id="digitalServiceList">
  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.publish_state" placeholder="请选择发布状态">
  9. <el-option label="未发布" value="0"></el-option>
  10. <el-option label="已发布" value="1"></el-option>
  11. </el-select>
  12. </el-col>-->
  13. <el-col :span="4">
  14. <span>输入条件:</span>
  15. <el-input v-model="search.title" :placeholder="placeholder" class="input"></el-input>
  16. </el-col>
  17. <!--<el-col :span="7">
  18. <span>时间选择:</span>
  19. <el-date-picker v-model="search.date" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker>
  20. </el-col>-->
  21. <el-col :span="8">
  22. <el-button class="btnSearch" @click="toQuery">查询</el-button>
  23. <el-button class="btnSearch qing" @click="toClear">清空</el-button>
  24. </el-col>
  25. </el-col>
  26. <el-col :span="24">
  27. <el-table
  28. ref="tableData"
  29. :data="tableData"
  30. tooltip-effect="dark"
  31. :default-sort="{ prop: 'date', order: 'descending' }"
  32. style="width: 100%"
  33. @selection-change="handleSelectionChange"
  34. >
  35. <!--<el-table-column type="selection" align="center"> </el-table-column>-->
  36. <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
  37. <el-table-column property="title" label="名称" align="center"> </el-table-column>
  38. <!--<el-table-column property="service" label="服务" align="center"> </el-table-column>-->
  39. <el-table-column label="图片" align="center">
  40. <template slot-scope="scope">
  41. <span> <el-image v-if="scope.row.image" :src="scope.row.image" style="height:20px;width:20px "
  42. @click="showImage(scope.row.image)"></el-image></span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column property="contact" label="联系人" align="center"> </el-table-column>
  46. <el-table-column property="phone" label="联系电话" align="center"> </el-table-column>
  47. <el-table-column property="email" label="电子邮箱" align="center"> </el-table-column>
  48. <el-table-column label="操作" align="center" width="300px">
  49. <template slot-scope="scope">
  50. <el-button size="mini" type="text" class="edit" icon="el-icon-edit"
  51. @click="$router.push({ path: '/digitalService/detail', query: { id: scope.row.id } })"></el-button>
  52. <el-button size="mini" type="text" class="delete" icon="el-icon-delete"
  53. @click.prevent="deleteRow(scope.row.id)"></el-button>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <el-row>
  58. <el-pagination
  59. @size-change="handleSizeChange"
  60. @current-change="handleCurrentChange"
  61. :current-page.sync="currentPage"
  62. :page-sizes="[10, 20, 30, 40]"
  63. :page-size.sync="limit"
  64. background
  65. layout="total, sizes, prev, pager, next, jumper"
  66. :total="total"
  67. >
  68. </el-pagination>
  69. </el-row>
  70. </el-col>
  71. </el-col>
  72. </el-row>
  73. <el-dialog
  74. :visible.sync="dialogVisible"
  75. width="30%"
  76. >
  77. <el-image :src="elImage" style="height:100%;width:100% "></el-image>
  78. </el-dialog>
  79. </div>
  80. </template>
  81. <script>
  82. export default {
  83. name: 'digitalServiceList',
  84. props: {
  85. tableData: null,
  86. total: null,
  87. type: null,
  88. },
  89. components: {},
  90. data: () => ({
  91. placeholder: '请输入名称',
  92. search: {},
  93. currentPage: 1,
  94. limit: 10,
  95. dialogVisible: false,
  96. elImage: '',
  97. }),
  98. created() {
  99. },
  100. computed: {
  101. },
  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,type:this.type, ...this.search});
  124. },
  125. handleCurrentChange(val) {
  126. this.$emit('select', {skip: (val - 1) * this.limit, limit: this.limit,type:this.type, ...this.search});
  127. },
  128. toQuery() {
  129. this.$set(this, `currentPage`, 1);
  130. this.$emit('select', {skip: 0, limit: this.limit,type:this.type, ...this.search});
  131. },
  132. toClear() {
  133. let keys = Object.keys(this.search);
  134. for (const key of keys) {
  135. this.$set(this.search, `${key}`, '');
  136. }
  137. },
  138. showImage(image) {
  139. if(image){
  140. this.$set(this, `elImage`, image);
  141. this.$set(this, `dialogVisible`, true);
  142. }else{
  143. this.$set(this, `dialogVisible`, false);
  144. }
  145. },
  146. getDate(val) {
  147. if(val){
  148. return this.format(new Date(Number(val)),'yyyy年MM月dd');
  149. }
  150. return '';
  151. },
  152. format(date,formatStr){
  153. formatStr=formatStr.replace(/yyyy|YYYY/,date.getFullYear());
  154. formatStr=formatStr.replace(/MM/,(date.getMonth()+1)>9?(date.getMonth()+1).toString():'0' + (date.getMonth()+1));
  155. formatStr=formatStr.replace(/dd|DD/,date.getDate()>9?date.getDate().toString():'0' + date.getDate());
  156. return formatStr;
  157. },
  158. publish(row){
  159. if(row.publish_state === '1'){
  160. this.$message.error('已发布');
  161. return ;
  162. }
  163. this.$emit('publish', {row:row,skip: (this.currentPage - 1) * this.limit, limit: this.limit, ...this.search});
  164. },
  165. },
  166. };
  167. </script>
  168. <style lang="less" scoped>
  169. /deep/ .el-checkbox__input.is-checked .el-checkbox__inner {
  170. background-color: red;
  171. border-color: red;
  172. }
  173. /deep/ .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  174. background-color: red;
  175. border-color: red;
  176. }
  177. /deep/ .el-table th {
  178. background-color: #f5f6fa;
  179. padding: 8px 0;
  180. }
  181. /deep/ .el-table td {
  182. padding: 11px 0;
  183. }
  184. .other {
  185. color: #f36302;
  186. }
  187. .view {
  188. color: #f36302;
  189. }
  190. .edit {
  191. color: #2ccc02;
  192. }
  193. .delete {
  194. color: #e9021d;
  195. }
  196. /deep/ .el-pagination {
  197. padding: 26px 20px;
  198. }
  199. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  200. background-color: red;
  201. }
  202. .input {
  203. width: 150px;
  204. }
  205. /deep/ .el-input__inner {
  206. height: 35px;
  207. line-height: 35px;
  208. }
  209. .btnSearch {
  210. width: 80px;
  211. height: 34px;
  212. background: rgba(233, 2, 29, 1);
  213. border-radius: 4px;
  214. padding: 0;
  215. color: #fff;
  216. }
  217. .qing {
  218. background: rgba(185, 185, 185, 1);
  219. }
  220. .top {
  221. height: 50px;
  222. margin: 0 0 10px 0;
  223. }
  224. .search {
  225. background: #ffffff;
  226. width: 97%;
  227. height: 35px;
  228. margin: 20px;
  229. margin-left: 0px;
  230. }
  231. .list {
  232. padding: 0 20px;
  233. }
  234. </style>