draw-management.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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="60" 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 prop="state" header-align="center" align="center" width="100" label="状态">
  78. <template slot-scope="scope">
  79. <el-tag :type="Number(scope.row.state) === 1 ? 'success' : 'danger'" disable-transitions>
  80. {{ Number(scope.row.state) === 1 ? '启用' : '停用' }}
  81. </el-tag>
  82. </template>
  83. </el-table-column>
  84. <el-table-column fixed="right" header-align="center" align="center" width="160" label="操作">
  85. <template slot-scope="scope">
  86. <!-- 查看 -->
  87. <el-button type="text" size="small" @click="detailHandle(scope.row.drawingId)">查看</el-button>
  88. <!-- 启用/停用 -->
  89. <el-button v-if="isAuth('pro:drawing:update')" type="text" size="small" @click="toggleState(scope.row)">
  90. {{ Number(scope.row.state) === 1 ? '停用' : '启用' }}
  91. </el-button>
  92. <!-- 打印 -->
  93. <el-button v-if="scope.row.attachList && scope.row.attachList.length" type="text" size="small"
  94. class="print-btn" @click="printImages(scope.row.attachList)">打印</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
  99. :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
  100. layout="total, sizes, prev, pager, next, jumper">
  101. </el-pagination>
  102. </template>
  103. <!-- 弹窗, 新增 / 修改 -->
  104. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"
  105. @onChose="onChose"></add-or-update>
  106. <detail v-if="detailVisible" ref="detail" @onChose="onChose" />
  107. <preview-component v-if="previewVisible" ref="preview" @onChose="onChose"></preview-component>
  108. <image-preview ref="imagePreview" />
  109. </div>
  110. </template>
  111. <script>
  112. import AddOrUpdate from './draw-add-or-update'
  113. import Detail from './draw-detail'
  114. import { getDrawList } from '@/api/product'
  115. import { printImages as printImagesUtil } from '@/utils/print-images'
  116. import ProductComponent from '@/views/modules/common/product-component'
  117. import PreviewComponent from '@/views/modules/common/preview-component.vue'
  118. import ImagePreview from '@/views/modules/common/image-preview.vue'
  119. import ImageViewerMixin from '@/views/modules/common/mixins/image-viewer-mixin'
  120. import { isAuth } from '@/utils'
  121. export default {
  122. name: 'draw-management',
  123. mixins: [ImageViewerMixin],
  124. components: {
  125. ProductComponent,
  126. AddOrUpdate,
  127. Detail,
  128. PreviewComponent,
  129. ImagePreview
  130. },
  131. data() {
  132. return {
  133. addOrUpdateVisible: false,
  134. previewVisible: false,
  135. detailVisible: false,
  136. dataForm: {
  137. keyword: ''
  138. },
  139. optionsProducts: [],
  140. dataList: [],
  141. pageIndex: 1,
  142. pageSize: 10,
  143. totalPage: 0,
  144. dataListLoading: false,
  145. dataListSelections: []
  146. }
  147. },
  148. created() {
  149. this.getDataList()
  150. },
  151. methods: {
  152. // 权限判断(从 utils 导入并暴露给模板使用)
  153. isAuth,
  154. onChose() {
  155. this.addOrUpdateVisible = false
  156. this.detailVisible = false
  157. },
  158. // 查询
  159. search() {
  160. this.pageIndex = 1
  161. this.getDataList()
  162. },
  163. // 获取数据列表
  164. getDataList() {
  165. this.addOrUpdateVisible = false
  166. this.dataListLoading = true
  167. let params = {
  168. 'current': this.pageIndex,
  169. 'size': this.pageSize,
  170. 'keyword': this.dataForm.keyword,
  171. 'createTime': this.dataForm.createTime ? this.dataForm.createTime : null,
  172. 'productId': this.dataForm.productId ? this.dataForm.productId : null
  173. }
  174. getDrawList(params).then(({ data }) => {
  175. if (data && data.code === '200') {
  176. this.dataList = data.data.records
  177. this.totalPage = Number(data.data.total)
  178. } else {
  179. this.dataList = []
  180. this.totalPage = 0
  181. }
  182. this.dataListLoading = false
  183. })
  184. },
  185. // 每页数
  186. sizeChangeHandle(val) {
  187. this.pageSize = val
  188. this.pageIndex = 1
  189. this.getDataList()
  190. },
  191. // 当前页
  192. currentChangeHandle(val) {
  193. this.pageIndex = val
  194. this.getDataList()
  195. },
  196. // 多选
  197. selectionChangeHandle(val) {
  198. this.dataListSelections = val
  199. },
  200. // 新增 / 修改
  201. addOrUpdateHandle(id, display) {
  202. this.addOrUpdateVisible = true
  203. this.$nextTick(() => {
  204. this.$refs.addOrUpdate.init(id, display)
  205. })
  206. },
  207. // 删除
  208. deleteHandle(id) {
  209. if (!id) return
  210. let ids = []
  211. ids.push(id)
  212. this.$confirm(`确定删除?`, '提示', {
  213. confirmButtonText: '确定',
  214. cancelButtonText: '取消',
  215. type: 'warning'
  216. }).then(() => {
  217. this.$http({
  218. url: this.$http.adornUrl(`/biz-service/drawing/delete`),
  219. method: 'DELETE',
  220. data: ids
  221. }).then(({ data }) => {
  222. if (data && data.code === '200') {
  223. this.$message({
  224. message: '操作成功',
  225. type: 'success',
  226. duration: 1500,
  227. onClose: () => {
  228. this.getDataList()
  229. }
  230. })
  231. } else {
  232. this.$message.error(data.msg)
  233. }
  234. })
  235. }).catch(() => { })
  236. },
  237. // 启用/停用
  238. toggleState(row) {
  239. if (!row || !row.drawingId) return
  240. const current = Number(row.state)
  241. const targetState = current === 1 ? 2 : 1
  242. const actionText = targetState === 1 ? '启用' : '停用'
  243. this.$confirm(`确定${actionText}该图纸?`, '提示', {
  244. confirmButtonText: '确定',
  245. cancelButtonText: '取消',
  246. type: 'warning'
  247. }).then(() => {
  248. this.$http({
  249. url: this.$http.adornUrl('/biz-service/drawing/update'),
  250. method: 'POST',
  251. data: {
  252. drawingId: row.drawingId,
  253. state: targetState
  254. }
  255. }).then(({ data }) => {
  256. if (data && data.code === '200') {
  257. this.$message({
  258. message: '操作成功',
  259. type: 'success',
  260. duration: 1500,
  261. onClose: () => {
  262. this.getDataList()
  263. }
  264. })
  265. } else {
  266. this.$message.error(data && data.msg ? data.msg : '操作失败')
  267. }
  268. })
  269. }).catch(() => { })
  270. },
  271. // 预览
  272. previewFile(fileName, url) {
  273. this.previewVisible = true
  274. this.$nextTick(() => {
  275. this.$refs.preview.init(fileName, url)
  276. })
  277. },
  278. // 详情
  279. detailHandle(id) {
  280. this.detailVisible = true
  281. this.$nextTick(() => {
  282. this.$refs.detail.init(id)
  283. })
  284. },
  285. // 打印图片
  286. printImages(attachList = []) {
  287. printImagesUtil(attachList, this)
  288. }
  289. }
  290. }
  291. </script>
  292. <style scoped>
  293. .print-btn {
  294. color: #11C26D;
  295. }
  296. </style>