routeModal.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <el-dialog title="选择工艺路线" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="false"
  3. :close-on-press-escape="false" append-to-body width="80%">
  4. <el-card shadow="never">
  5. <routetSearch @search="reload" />
  6. <!-- 表格 -->
  7. <ele-pro-table ref="table" :columns="columns" :datasource="datasource" height="calc(100vh - 350px)"
  8. :need-page="true" class="dict-table" @cell-click="cellClick">
  9. <!-- 状态列 -->
  10. <template v-slot:status="{ row }">
  11. {{ checkStatus(row) }}
  12. </template>
  13. <!-- 表头工具栏 -->
  14. <template v-slot:action="{ row }">
  15. <el-radio class="radio" v-model="radio" :label="row.id"><i></i></el-radio>
  16. </template>
  17. </ele-pro-table>
  18. </el-card>
  19. <div class="btns">
  20. <el-button type="primary" size="small" @click="selected">选择</el-button>
  21. <el-button size="small" @click="handleClose">关闭</el-button>
  22. </div>
  23. </el-dialog>
  24. </template>
  25. <script>
  26. import AssetTree from '@/components/AssetTree';
  27. import routetSearch from './route-search.vue'
  28. import route from '@/api/technology/route';
  29. export default {
  30. components: { AssetTree, routetSearch },
  31. data() {
  32. return {
  33. visible: false,
  34. // 表格列配置
  35. columns: [
  36. {
  37. prop: 'code',
  38. label: '工艺路线组编码',
  39. showOverflowTooltip: true,
  40. align: 'center',
  41. minWidth: 110
  42. },
  43. {
  44. prop: 'name',
  45. label: '工艺路线名称',
  46. showOverflowTooltip: true,
  47. align: 'center',
  48. minWidth: 110
  49. },
  50. {
  51. align: 'center',
  52. prop: 'categoryCode',
  53. label: '产品编码',
  54. showOverflowTooltip: true,
  55. minWidth: 110
  56. },
  57. {
  58. prop: 'categoryName',
  59. label: '产品名称',
  60. align: 'center',
  61. showOverflowTooltip: true,
  62. minWidth: 110
  63. },
  64. {
  65. prop: 'version',
  66. label: '工艺路线版本',
  67. align: 'center',
  68. showOverflowTooltip: true,
  69. minWidth: 110
  70. },
  71. {
  72. prop: 'status',
  73. label: '状态',
  74. align: 'center',
  75. slot: 'status',
  76. showOverflowTooltip: true,
  77. minWidth: 110
  78. },
  79. {
  80. action: 'action',
  81. slot: 'action',
  82. align: 'center',
  83. label: '选择'
  84. }
  85. ],
  86. radio: null,
  87. statusList: [
  88. { label: '草稿', value: -1 },
  89. { label: '失效', value: 0 },
  90. { label: '生效', value: 1 }
  91. ],
  92. }
  93. },
  94. watch: {
  95. },
  96. methods: {
  97. /* 表格数据源 */
  98. async datasource({ page, limit, where, order }) {
  99. const res = await route.list({
  100. ...where,
  101. ...order,
  102. pageNum: page,
  103. size: limit
  104. });
  105. return res;
  106. },
  107. checkStatus(row) {
  108. let obj = this.statusList.find((it) => it.value == row.status);
  109. return obj.label;
  110. },
  111. /* 刷新表格 */
  112. reload() {
  113. this.$refs.table.reload();
  114. },
  115. open(item) {
  116. if (item) {
  117. this.current = {
  118. id: item.routingId,
  119. name: item.routingName,
  120. code: item.routingCode
  121. }
  122. this.radio = item.routingId
  123. }
  124. this.visible = true
  125. },
  126. // 单击获取id
  127. cellClick(row) {
  128. this.current = row
  129. this.radio = row.id
  130. },
  131. handleClose() {
  132. this.visible = false
  133. this.current = null
  134. this.radio = ''
  135. },
  136. selected() {
  137. console.log(this.current)
  138. if (!this.current) {
  139. return this.$message.warning('请选择工艺路线')
  140. }
  141. this.$emit('changeRoute', this.current)
  142. this.handleClose()
  143. },
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .table_col {
  149. padding-left: 10px;
  150. ::v-deep .el-table th.el-table__cell {
  151. background: #f2f2f2;
  152. }
  153. }
  154. .pagination {
  155. text-align: right;
  156. padding: 10px 0;
  157. }
  158. .btns {
  159. text-align: center;
  160. padding: 10px 0;
  161. }
  162. </style>