workshop-manage.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <!-- 车间管理 -->
  2. <template>
  3. <div>
  4. <template v-if="!addOrUpdateVisible && !detailVisible">
  5. <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
  6. <el-form-item label="名称">
  7. <el-input v-model="dataForm.name" placeholder="" clearable />
  8. </el-form-item>
  9. <el-form-item>
  10. <el-button @click="queryData()">查询</el-button>
  11. <el-button type="primary" @click="addOrUpdateHandle(0, false)">新增</el-button>
  12. </el-form-item>
  13. </el-form>
  14. <el-table :data="dataList" border v-loading="dataListLoading" style="width: 100%;">
  15. <el-table-column label="序号" type="index" width="50" align="center">
  16. </el-table-column>
  17. <el-table-column prop="name" header-align="center" align="center" min-width="140"
  18. :show-tooltip-when-overflow="true" label="名称">
  19. </el-table-column>
  20. <el-table-column prop="description" header-align="center" align="center" min-width="160"
  21. :show-tooltip-when-overflow="true" label="描述">
  22. </el-table-column>
  23. <el-table-column prop="workTypeNameList" header-align="center" align="center" min-width="160"
  24. :show-tooltip-when-overflow="true" label="工种">
  25. </el-table-column>
  26. <el-table-column prop="workshopManager" header-align="center" align="center" min-width="120" fixed="right"
  27. :show-tooltip-when-overflow="true" label="主管">
  28. <template slot-scope="scope">
  29. <span>{{ scope.row.workshopManagerName }}</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column prop="notes" header-align="center" align="center" :show-tooltip-when-overflow="true"
  33. label="备注">
  34. </el-table-column>
  35. <el-table-column prop="createTime" header-align="center" align="center" min-width="120"
  36. :show-tooltip-when-overflow="true" label="创建时间">
  37. </el-table-column>
  38. <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
  39. <template slot-scope="scope">
  40. <el-button type="text" size="small" @click="detailHandle(scope.row.proWorkshopId)">查看</el-button>
  41. <el-button type="text" size="small"
  42. @click="addOrUpdateHandle(scope.row.proWorkshopId, false)">编辑</el-button>
  43. <el-button type="text" size="small" style="color: red"
  44. @click="deleteHandle(scope.row.proWorkshopId)">删除</el-button>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
  49. :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
  50. layout="total, sizes, prev, pager, next, jumper">
  51. </el-pagination>
  52. </template>
  53. <!-- 弹窗, 新增 / 修改 -->
  54. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"
  55. @onChose="onChose"></add-or-update>
  56. <detail v-if="detailVisible" ref="detail" @onChose="onChose" />
  57. <attach-detail-dialog ref="attachDetail" @onChose="onChose" />
  58. </div>
  59. </template>
  60. <script>
  61. import AddOrUpdate from './workshop-add-or-update'
  62. import Detail from './workshop-detail'
  63. import { getList, remove } from '@/api/workshop' // 补充引入 remove 方法
  64. import AttachDetailDialog from '../common/attach-detail-dialog'
  65. export default {
  66. name: 'workshop-manage',
  67. components: {
  68. AddOrUpdate, Detail, AttachDetailDialog
  69. },
  70. data() {
  71. return {
  72. addOrUpdateVisible: false,
  73. detailVisible: false,
  74. dataForm: {},
  75. dataList: [],
  76. pageIndex: 1,
  77. pageSize: 10,
  78. totalPage: 0,
  79. dataListLoading: false,
  80. dataListSelections: [],
  81. optionsLevel: []
  82. }
  83. },
  84. created() {
  85. this.getDataList()
  86. },
  87. methods: {
  88. onChose() {
  89. this.addOrUpdateVisible = false
  90. this.detailVisible = false
  91. },
  92. // 查询
  93. queryData() {
  94. this.pageIndex = 1
  95. this.getDataList()
  96. },
  97. // 获取数据列表
  98. getDataList() {
  99. this.dataListLoading = true
  100. this.addOrUpdateVisible = false
  101. let params = {
  102. 'current': this.pageIndex,
  103. 'size': this.pageSize,
  104. 'name': this.dataForm.name ? this.dataForm.name : null
  105. }
  106. getList(params).then(({ data }) => {
  107. if (data && data.code === '200') {
  108. this.dataList = data.data.records
  109. this.totalPage = Number(data.data.total)
  110. } else {
  111. this.dataList = []
  112. this.totalPage = 0
  113. }
  114. this.dataListLoading = false
  115. })
  116. },
  117. // 每页数
  118. sizeChangeHandle(val) {
  119. this.pageSize = val
  120. this.pageIndex = 1
  121. this.getDataList()
  122. },
  123. // 当前页
  124. currentChangeHandle(val) {
  125. this.pageIndex = val
  126. this.getDataList()
  127. },
  128. // 多选
  129. selectionChangeHandle(val) {
  130. this.dataListSelections = val
  131. },
  132. // 新增 / 修改
  133. addOrUpdateHandle(id, disable) {
  134. this.addOrUpdateVisible = true
  135. this.$nextTick(() => {
  136. this.$refs.addOrUpdate.init(id, disable)
  137. })
  138. },
  139. // 详情
  140. detailHandle(id) {
  141. this.detailVisible = true
  142. this.$nextTick(() => {
  143. this.$refs.detail.init(id)
  144. })
  145. },
  146. attachDetails(attachList) {
  147. this.$refs.attachDetail.init(attachList)
  148. },
  149. // 删除
  150. deleteHandle(id) {
  151. this.$confirm('确定要删除该车间吗?', '提示', {
  152. confirmButtonText: '确定',
  153. cancelButtonText: '取消',
  154. type: 'warning'
  155. }).then(() => {
  156. this.dataListLoading = true
  157. let ids = []
  158. ids.push(id)
  159. // 调用删除接口
  160. remove(ids).then(({ data }) => {
  161. this.dataListLoading = false
  162. if (data && data.code === '200') {
  163. this.$message.success('删除成功')
  164. this.getDataList()
  165. } else {
  166. this.$message.error(data && data.msg ? data.msg : '删除失败')
  167. }
  168. }).catch(() => {
  169. this.dataListLoading = false
  170. })
  171. }).catch(() => { })
  172. },
  173. }
  174. }
  175. </script>
  176. <style scoped></style>