printPicLib.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="mod-print-printPicLib">
  3. <!-- 搜索相关区域 -->
  4. <div class="search-bar">
  5. <el-form :inline="true" class="search-form" ref="searchForm" :model="searchForm" label-width="auto" size="small">
  6. <!-- 表单项 -->
  7. <div class="input-row">
  8. <el-form-item prop="prodId" label="关联产品">
  9. <el-select v-model="searchForm.prodId" clearable filterable>
  10. <el-option
  11. v-for="node in prodList"
  12. :key="node.prodId"
  13. :label="node.prodName"
  14. :value="node.prodId"
  15. ></el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item prop="category" label="分类">
  19. <el-input v-model="searchForm.category"></el-input>
  20. </el-form-item>
  21. <el-form-item>
  22. <div class="default-btn primary-btn" @click="searchChange()">{{ $t('crud.searchBtn') }}</div>
  23. <div class="default-btn" @click="resetForm()">{{ $t('shop.resetMap') }}</div>
  24. </el-form-item>
  25. </div>
  26. </el-form>
  27. </div>
  28. <!-- 列表相关区域 -->
  29. <div class="main-container">
  30. <div class="operation-bar">
  31. <div class="default-btn primary-btn" @click="addOrUpdateHandle()">{{$t("crud.addTitle")}}</div>
  32. </div>
  33. <div class="table-con spec-table">
  34. <el-table
  35. ref="specListTable"
  36. :data="dataList"
  37. header-cell-class-name="table-header"
  38. row-class-name="table-row"
  39. style="width: 100%">
  40. <!-- 正面图 -->
  41. <el-table-column label="正面" prop="frontUrl" align="center">
  42. <template slot-scope="scope">
  43. <el-image
  44. style="width: 100px; height: 100px"
  45. :src="resourcesUrl + scope.row.frontUrl"
  46. v-if="scope.row.frontUrl"
  47. fit="fill"
  48. @click="previewPic(scope.row.frontUrl)"
  49. />
  50. </template>
  51. </el-table-column>
  52. <!-- 背面图 -->
  53. <el-table-column label="背面" prop="backUrl" align="center">
  54. <template slot-scope="scope">
  55. <el-image
  56. style="width: 100px; height: 100px"
  57. :src="resourcesUrl + scope.row.backUrl"
  58. v-if="scope.row.backUrl"
  59. fit="fill"
  60. @click="previewPic(scope.row.backUrl)"
  61. />
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="关联产品" prop="prodName" align="center">
  65. <template slot-scope="scope">
  66. <span>{{ scope.row.prodName}}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="分类" prop="category" align="center">
  70. <template slot-scope="scope">
  71. <span>{{ scope.row.category}}</span>
  72. </template>
  73. </el-table-column>
  74. <!-- 排序序号 -->
  75. <el-table-column label="序号" prop="seq" align="center">
  76. <template slot-scope="scope">
  77. <span>{{ scope.row.seq}}</span>
  78. </template>
  79. </el-table-column>
  80. <!-- 是否删除,0正常,1删除 -->
  81. <el-table-column label="是否删除" prop="isDelete" align="center">
  82. <template slot-scope="scope">
  83. <el-tag v-if="scope.row.isDelete === 1" type="danger">已删除</el-tag>
  84. <el-tag v-if="scope.row.isDelete === 0" type="success">正常</el-tag>
  85. </template>
  86. </el-table-column>
  87. <el-table-column align="center" fixed="right" :label="$t('publics.operating')" width="auto">
  88. <template slot-scope="scope">
  89. <div class="text-btn-con">
  90. <div class="default-btn text-btn" @click="addOrUpdateHandle(scope.row.id)">{{$t("crud.updateBtn")}}</div>
  91. <div class="default-btn text-btn" @click.stop="deleteHandle(scope.row.id)">{{$t("text.delBtn")}}</div>
  92. </div>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. </div>
  97. <el-pagination
  98. v-if="dataList.length"
  99. @size-change="handleSizeChange"
  100. @current-change="handleCurrentChange"
  101. :current-page="page.currentPage"
  102. :page-sizes="[10, 20, 50, 100]"
  103. :page-size="page.pageSize"
  104. layout="total, sizes, prev, pager, next, jumper"
  105. :total="page.total">
  106. </el-pagination>
  107. </div>
  108. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="refreshChange"></add-or-update>
  109. <el-dialog :visible.sync="previewPicDialogVisible" :modal="false" title="图片预览" width="30%" top="3vh">
  110. <el-image :src="previewPicUrl" alt="" style="width: 100%; height: 100%"/>
  111. </el-dialog>
  112. </div>
  113. </template>
  114. <script>
  115. import AddOrUpdate from './printPicLib-add-or-update'
  116. export default {
  117. data () {
  118. return {
  119. dataList: [],
  120. page: {
  121. total: 0, // 总页数
  122. currentPage: 1, // 当前页数
  123. pageSize: 10 // 每页显示多少条
  124. },
  125. categoryList:[],
  126. prodList:[],
  127. previewPicUrl: null,
  128. previewPicDialogVisible: false,
  129. resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
  130. searchForm: {
  131. prodId: null
  132. }, // 搜索
  133. dataListLoading: false,
  134. addOrUpdateVisible: false
  135. }
  136. },
  137. components: {
  138. AddOrUpdate
  139. },
  140. created () {
  141. this.getDataList();
  142. this.getProdList();
  143. },
  144. mounted () {
  145. },
  146. methods: {
  147. getProdList(){
  148. this.$http({
  149. url: this.$http.adornUrl('/prod/prod/simpleList'),
  150. method: 'GET',
  151. params: this.$http.adornParams({customized:0})
  152. }).then(({data}) => {
  153. this.prodList = data
  154. })
  155. },
  156. previewPic(url){
  157. this.previewPicUrl = this.resourcesUrl + url;
  158. this.previewPicDialogVisible = true;
  159. },
  160. getDataList (page) {
  161. this.dataListLoading = true;
  162. this.$http({
  163. url: this.$http.adornUrl('/print/printPicLib/page'),
  164. method: 'get',
  165. params: this.$http.adornParams(
  166. Object.assign({
  167. current: page == null ? this.page.currentPage : page.currentPage,
  168. size: page == null ? this.page.pageSize : page.pageSize
  169. },
  170. this.searchForm
  171. )
  172. )
  173. }).then(({data}) => {
  174. this.dataList = data.records
  175. this.page.total = data.total
  176. this.dataListLoading = false
  177. })
  178. },
  179. // 新增 / 修改
  180. addOrUpdateHandle (id) {
  181. this.addOrUpdateVisible = true;
  182. this.$nextTick(() => {
  183. this.$refs.addOrUpdate.init(id)
  184. })
  185. },
  186. deleteHandle (id) {
  187. this.$confirm(this.$i18n.t('admin.isDeleOper') + '?', this.$i18n.t('text.tips'), {
  188. confirmButtonText: this.$i18n.t('crud.filter.submitBtn'),
  189. cancelButtonText: this.$i18n.t('crud.filter.cancelBtn'),
  190. type: 'warning'
  191. }).then(() => {
  192. this.$http({
  193. url: this.$http.adornUrl('/print/printPicLib/' + id),
  194. method: 'delete',
  195. data: this.$http.adornData({})
  196. }).then(({ data }) => {
  197. this.$message({
  198. message: this.$i18n.t('publics.operation'),
  199. type: 'success',
  200. duration: 1500,
  201. onClose: () => {
  202. this.refreshChange()
  203. }
  204. })
  205. })
  206. }).catch(() => { })
  207. },
  208. // 刷新回调
  209. refreshChange () {
  210. this.page.currentPage = 1
  211. this.getDataList(this.page)
  212. },
  213. resetForm () {
  214. this.searchForm = {
  215. prodId: null,
  216. }
  217. },
  218. searchChange (params) {
  219. this.getDataList(this.page)
  220. },
  221. handleSizeChange (val) {
  222. this.page.pageSize = val
  223. this.getDataList()
  224. },
  225. handleCurrentChange (val) {
  226. this.page.currentPage = val
  227. this.getDataList()
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="scss">
  233. .mod-print-printPicLib {
  234. }
  235. </style>