draw-management.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <!-- 图库管理 -->
  2. <template>
  3. <div class="draw-management">
  4. <template v-if="!addOrUpdateVisible && !detailVisible">
  5. <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
  6. <el-form-item label="名称">
  7. <el-input v-model="dataForm.keyword" placeholder="名称" clearable />
  8. </el-form-item>
  9. <el-form-item label="创建日期">
  10. <el-date-picker v-model="dataForm.date" value-format="yyyy-MM-dd" type="daterange" range-separator="至"
  11. start-placeholder="开始日期" end-placeholder="结束日期">
  12. </el-date-picker>
  13. </el-form-item>
  14. <el-form-item label="物料" prop="productId">
  15. <product-component v-model="dataForm.productId" :product-id.sync="dataForm.productId"></product-component>
  16. </el-form-item>
  17. <el-form-item>
  18. <el-button @click="search()">查询</el-button>
  19. <el-button v-if="isAuth('pro:drawing:save')" type="primary"
  20. @click="addOrUpdateHandle(0, false)">上传图纸</el-button>
  21. </el-form-item>
  22. </el-form>
  23. <el-table :data="dataList" border v-loading="dataListLoading" style="width: 100%;">
  24. <el-table-column label="序号" type="index" width="50" align="center">
  25. </el-table-column>
  26. <!-- <el-table-column
  27. prop="drawingCode"
  28. header-align="center"
  29. align="center"
  30. min-width="100"
  31. :show-tooltip-when-overflow="true"
  32. label="图纸编码">
  33. </el-table-column> -->
  34. <el-table-column prop="drawingName" header-align="center" align="center" min-width="120"
  35. :show-tooltip-when-overflow="true" label="图纸名称">
  36. </el-table-column>
  37. <el-table-column prop="drawingNo" header-align="center" align="center" min-width="120"
  38. :show-tooltip-when-overflow="true" label="图号">
  39. </el-table-column>
  40. <el-table-column prop="version" header-align="center" align="center" min-width="120"
  41. :show-tooltip-when-overflow="true" label="版本">
  42. </el-table-column>
  43. <el-table-column header-align="center" align="center" min-width="50" label="图纸文件">
  44. <template slot-scope="scope">
  45. <el-button v-if="scope.row.attachList && scope.row.attachList.length" type="text" size="small"
  46. @click="openImagePreview(scope.row.attachList)">
  47. 查看({{ scope.row.attachList.length }})
  48. </el-button>
  49. <el-button v-else type="text" size="small" disabled>
  50. 查看(0)
  51. </el-button>
  52. </template>
  53. </el-table-column>
  54. <!-- <el-table-column
  55. prop="productName"
  56. header-align="center"
  57. align="center"
  58. min-width="140"
  59. :show-tooltip-when-overflow="true"
  60. label="对应物料">
  61. </el-table-column>
  62. <el-table-column
  63. prop="source"
  64. header-align="center"
  65. align="center"
  66. min-width="200"
  67. :show-overflow-tooltip="true"
  68. label="来源">
  69. </el-table-column> -->
  70. <el-table-column prop="createTime" header-align="center" align="center" min-width="160" label="上传时间">
  71. </el-table-column>
  72. <el-table-column prop="creatorName" header-align="center" align="center" min-width="100" label="上传人">
  73. </el-table-column>
  74. <el-table-column prop="notes" header-align="center" align="center" min-width="180" :show-overflow-tooltip="true"
  75. label="备注">
  76. </el-table-column>
  77. <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
  78. <template slot-scope="scope">
  79. <el-button type="text" size="small" @click="detailHandle(scope.row.drawingId)">删除</el-button>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
  84. :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
  85. layout="total, sizes, prev, pager, next, jumper">
  86. </el-pagination>
  87. </template>
  88. <!-- 弹窗, 新增 / 修改 -->
  89. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"
  90. @onChose="onChose"></add-or-update>
  91. <detail v-if="detailVisible" ref="detail" @onChose="onChose" />
  92. <preview-component v-if="previewVisible" ref="preview" @onChose="onChose"></preview-component>
  93. <image-preview ref="imagePreview" />
  94. </div>
  95. </template>
  96. <script>
  97. import AddOrUpdate from './draw-add-or-update'
  98. import Detail from './draw-detail'
  99. import { getDrawList } from '@/api/product'
  100. import ProductComponent from '@/views/modules/common/product-component'
  101. import PreviewComponent from '@/views/modules/common/preview-component.vue'
  102. import ImagePreview from '@/views/modules/common/image-preview.vue'
  103. import ImageViewerMixin from '@/views/modules/common/mixins/image-viewer-mixin'
  104. export default {
  105. name: 'draw-management',
  106. mixins: [ImageViewerMixin],
  107. components: {
  108. ProductComponent,
  109. AddOrUpdate,
  110. Detail,
  111. PreviewComponent,
  112. ImagePreview
  113. },
  114. data() {
  115. return {
  116. addOrUpdateVisible: false,
  117. previewVisible: false,
  118. detailVisible: false,
  119. dataForm: {
  120. keyword: ''
  121. },
  122. optionsProducts: [],
  123. dataList: [],
  124. pageIndex: 1,
  125. pageSize: 10,
  126. totalPage: 0,
  127. dataListLoading: false,
  128. dataListSelections: []
  129. }
  130. },
  131. created() {
  132. this.getDataList()
  133. },
  134. methods: {
  135. onChose() {
  136. this.addOrUpdateVisible = false
  137. this.detailVisible = false
  138. },
  139. // 查询
  140. search() {
  141. this.pageIndex = 1
  142. this.getDataList()
  143. },
  144. // 获取数据列表
  145. getDataList() {
  146. this.addOrUpdateVisible = false
  147. this.dataListLoading = true
  148. let params = {
  149. 'current': this.pageIndex,
  150. 'size': this.pageSize,
  151. 'keyword': this.dataForm.keyword,
  152. 'createTime': this.dataForm.createTime ? this.dataForm.createTime : null,
  153. 'productId': this.dataForm.productId ? this.dataForm.productId : null
  154. }
  155. getDrawList(params).then(({ data }) => {
  156. if (data && data.code === '200') {
  157. this.dataList = data.data.records
  158. this.totalPage = Number(data.data.total)
  159. } else {
  160. this.dataList = []
  161. this.totalPage = 0
  162. }
  163. this.dataListLoading = false
  164. })
  165. },
  166. // 每页数
  167. sizeChangeHandle(val) {
  168. this.pageSize = val
  169. this.pageIndex = 1
  170. this.getDataList()
  171. },
  172. // 当前页
  173. currentChangeHandle(val) {
  174. this.pageIndex = val
  175. this.getDataList()
  176. },
  177. // 多选
  178. selectionChangeHandle(val) {
  179. this.dataListSelections = val
  180. },
  181. // 新增 / 修改
  182. addOrUpdateHandle(id, display) {
  183. this.addOrUpdateVisible = true
  184. this.$nextTick(() => {
  185. this.$refs.addOrUpdate.init(id, display)
  186. })
  187. },
  188. // 删除
  189. deleteHandle(id) {
  190. if (!id) return
  191. let ids = []
  192. ids.push(id)
  193. this.$confirm(`确定删除?`, '提示', {
  194. confirmButtonText: '确定',
  195. cancelButtonText: '取消',
  196. type: 'warning'
  197. }).then(() => {
  198. this.$http({
  199. url: this.$http.adornUrl(`/biz-service/drawing/delete`),
  200. method: 'DELETE',
  201. data: ids
  202. }).then(({ data }) => {
  203. if (data && data.code === '200') {
  204. this.$message({
  205. message: '操作成功',
  206. type: 'success',
  207. duration: 1500,
  208. onClose: () => {
  209. this.getDataList()
  210. }
  211. })
  212. } else {
  213. this.$message.error(data.msg)
  214. }
  215. })
  216. }).catch(() => { })
  217. },
  218. // 预览
  219. previewFile(fileName, url) {
  220. this.previewVisible = true
  221. this.$nextTick(() => {
  222. this.$refs.preview.init(fileName, url)
  223. })
  224. },
  225. // 详情
  226. detailHandle(id) {
  227. this.detailVisible = true
  228. this.$nextTick(() => {
  229. this.$refs.detail.init(id)
  230. })
  231. }
  232. }
  233. }
  234. </script>
  235. <style scoped></style>