index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <el-card class="box-card">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" @submit.native.prevent>
  4. <el-form-item label="名称" prop="name">
  5. <el-input v-model="queryParams.name" placeholder="请输入名称" size="small" @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item label="风格" prop="style">
  8. <el-select v-model="queryParams.style" placeholder="请选择风格" size="small" style="width: 100%" @change="handleQuery">
  9. <el-option v-for="item in style" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  10. </el-select>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button size="small" @click="handleQuery" class="searchBtn">搜索</el-button>
  14. <el-button size="small" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" style="margin-bottom: 10px">
  18. <el-col :span="1.5">
  19. <el-button type="primary" size="mini" @click="handleAdd" v-db-click>新增</el-button>
  20. </el-col>
  21. </el-row>
  22. <el-table :data="tableList" :cell-style="{ padding: '0' }" :row-style="{ height: '35px' }" v-loading="loading" header-row-class-name="tableHeader">
  23. <el-table-column label="名称" prop="name" />
  24. <el-table-column label="素材图片" align="center">
  25. <template slot-scope="scope">
  26. <div style="padding: 4px 0">
  27. <img
  28. v-if="scope.row.mags"
  29. style="width: 80px; height: 80px; border: none"
  30. :src="pathPrefix + scope.row.mags"
  31. @click="openPicture(pathPrefix + scope.row.mags)"
  32. />
  33. </div>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="风格" align="center" :formatter="styleFormat" />
  37. <el-table-column label="操作" align="center" width="140" fixed="right">
  38. <template slot-scope="scope">
  39. <el-button type="text" @click="clickUpdate(scope.row)" v-db-click>修改</el-button>
  40. <el-button type="text" @click="clickRemove(scope.row)" v-db-click>删除</el-button>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  45. <!-- 添加或修改 -->
  46. <el-dialog :title="title" v-if="open" :visible.sync="open" width="30%" append-to-body>
  47. <AddOrModified :rowData="rowData" @clickCancel="clickCancel"></AddOrModified>
  48. </el-dialog>
  49. </el-card>
  50. </template>
  51. <script>
  52. import * as API from '@/api/shengde/group/material/lineDraft'
  53. import AddOrModified from './addOrModified'
  54. import { mapGetters } from 'vuex'
  55. export default {
  56. name: 'lineDraft',
  57. components: { AddOrModified },
  58. data() {
  59. return {
  60. pathPrefix: process.env.VUE_APP_IMG_URL,
  61. queryParams: {
  62. pageNum: 1,
  63. pageSize: 10,
  64. name: '',
  65. style: '',
  66. },
  67. loading: false,
  68. tableList: [],
  69. total: 0,
  70. title: '',
  71. rowData: {},
  72. open: '',
  73. style: [],
  74. }
  75. },
  76. created() {
  77. this.style = this.dictData.filter((item) => item.code === 'style')[0].children
  78. },
  79. mounted() {
  80. this.getList()
  81. },
  82. computed: mapGetters(['dictData']),
  83. methods: {
  84. getList() {
  85. this.loading = true
  86. API.lineList(this.queryParams).then(
  87. (res) => {
  88. this.tableList = res.data.data.records
  89. this.total = res.data.data.total
  90. this.loading = false
  91. },
  92. (err) => {
  93. console.log('lineList: ' + err)
  94. this.loading = false
  95. }
  96. )
  97. },
  98. /** 搜索按钮操作 */
  99. handleQuery() {
  100. this.queryParams.pageNum = 1
  101. this.getList()
  102. },
  103. /** 重置按钮操作 */
  104. resetQuery() {
  105. this.resetForm('queryForm')
  106. this.handleQuery()
  107. },
  108. handleAdd() {
  109. this.title = '新增线稿素材'
  110. this.rowData = {}
  111. this.open = true
  112. },
  113. clickUpdate(row) {
  114. this.title = '修改线稿素材'
  115. this.rowData = row
  116. this.open = true
  117. },
  118. clickRemove(row) {
  119. this.$confirm('是否确认删除此条数据项?', '警告', {
  120. confirmButtonText: '确定',
  121. cancelButtonText: '取消',
  122. type: 'warning',
  123. })
  124. .then(() => {
  125. API.lineDelete({ id: row.id }).then(() => {
  126. this.msgSuccess('删除成功!')
  127. this.getList()
  128. })
  129. })
  130. .catch(() => {})
  131. },
  132. clickCancel(status) {
  133. this.open = false
  134. if (status) {
  135. this.getList()
  136. }
  137. },
  138. styleFormat(row) {
  139. return this.selectConstantsLabel(this.style, row.style)
  140. },
  141. openPicture(path) {
  142. window.open(path)
  143. },
  144. },
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. * {
  149. font-size: 12px;
  150. }
  151. .box-card {
  152. height: calc(100vh - 110px);
  153. overflow-y: auto;
  154. }
  155. .searchBtn {
  156. background: #20b2aa;
  157. color: #fff;
  158. border: 1px solid #20b2aa;
  159. }
  160. ::v-deep {
  161. .el-input__inner {
  162. border-radius: 1px;
  163. }
  164. .el-button--small {
  165. border-radius: 1px;
  166. }
  167. .tableHeader th {
  168. background-color: #edf0f5;
  169. height: 35px;
  170. padding: 0;
  171. }
  172. }
  173. </style>