123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <!-- 车间管理 -->
- <template>
- <div>
- <template v-if="!addOrUpdateVisible && !detailVisible">
- <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
- <el-form-item label="名称">
- <el-input v-model="dataForm.name" placeholder="" clearable />
- </el-form-item>
- <el-form-item>
- <el-button @click="queryData()">查询</el-button>
- <el-button type="primary" @click="addOrUpdateHandle(0, false)">新增</el-button>
- </el-form-item>
- </el-form>
- <el-table :data="dataList" border v-loading="dataListLoading" style="width: 100%;">
- <el-table-column label="序号" type="index" width="50" align="center">
- </el-table-column>
- <el-table-column prop="name" header-align="center" align="center" min-width="140"
- :show-tooltip-when-overflow="true" label="名称">
- </el-table-column>
- <el-table-column prop="description" header-align="center" align="center" min-width="160"
- :show-tooltip-when-overflow="true" label="描述">
- </el-table-column>
- <el-table-column prop="workTypeNameList" header-align="center" align="center" min-width="160"
- :show-tooltip-when-overflow="true" label="工种">
- </el-table-column>
- <el-table-column prop="workshopManager" header-align="center" align="center" min-width="120" fixed="right"
- :show-tooltip-when-overflow="true" label="主管">
- <template slot-scope="scope">
- <span>{{ scope.row.workshopManagerName }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="notes" header-align="center" align="center" :show-tooltip-when-overflow="true"
- label="备注">
- </el-table-column>
- <el-table-column prop="createTime" header-align="center" align="center" min-width="120"
- :show-tooltip-when-overflow="true" label="创建时间">
- </el-table-column>
- <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
- <template slot-scope="scope">
- <el-button type="text" size="small" @click="detailHandle(scope.row.proWorkshopId)">查看</el-button>
- <el-button type="text" size="small"
- @click="addOrUpdateHandle(scope.row.proWorkshopId, false)">编辑</el-button>
- <el-button type="text" size="small" style="color: red"
- @click="deleteHandle(scope.row.proWorkshopId)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
- :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
- layout="total, sizes, prev, pager, next, jumper">
- </el-pagination>
- </template>
- <!-- 弹窗, 新增 / 修改 -->
- <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"
- @onChose="onChose"></add-or-update>
- <detail v-if="detailVisible" ref="detail" @onChose="onChose" />
- <attach-detail-dialog ref="attachDetail" @onChose="onChose" />
- </div>
- </template>
- <script>
- import AddOrUpdate from './workshop-add-or-update'
- import Detail from './workshop-detail'
- import { getList, remove } from '@/api/workshop' // 补充引入 remove 方法
- import AttachDetailDialog from '../common/attach-detail-dialog'
- export default {
- name: 'workshop-manage',
- components: {
- AddOrUpdate, Detail, AttachDetailDialog
- },
- data() {
- return {
- addOrUpdateVisible: false,
- detailVisible: false,
- dataForm: {},
- dataList: [],
- pageIndex: 1,
- pageSize: 10,
- totalPage: 0,
- dataListLoading: false,
- dataListSelections: [],
- optionsLevel: []
- }
- },
- created() {
- this.getDataList()
- },
- methods: {
- onChose() {
- this.addOrUpdateVisible = false
- this.detailVisible = false
- },
- // 查询
- queryData() {
- this.pageIndex = 1
- this.getDataList()
- },
- // 获取数据列表
- getDataList() {
- this.dataListLoading = true
- this.addOrUpdateVisible = false
- let params = {
- 'current': this.pageIndex,
- 'size': this.pageSize,
- 'name': this.dataForm.name ? this.dataForm.name : null
- }
- getList(params).then(({ data }) => {
- if (data && data.code === '200') {
- this.dataList = data.data.records
- this.totalPage = Number(data.data.total)
- } else {
- this.dataList = []
- this.totalPage = 0
- }
- this.dataListLoading = false
- })
- },
- // 每页数
- sizeChangeHandle(val) {
- this.pageSize = val
- this.pageIndex = 1
- this.getDataList()
- },
- // 当前页
- currentChangeHandle(val) {
- this.pageIndex = val
- this.getDataList()
- },
- // 多选
- selectionChangeHandle(val) {
- this.dataListSelections = val
- },
- // 新增 / 修改
- addOrUpdateHandle(id, disable) {
- this.addOrUpdateVisible = true
- this.$nextTick(() => {
- this.$refs.addOrUpdate.init(id, disable)
- })
- },
- // 详情
- detailHandle(id) {
- this.detailVisible = true
- this.$nextTick(() => {
- this.$refs.detail.init(id)
- })
- },
- attachDetails(attachList) {
- this.$refs.attachDetail.init(attachList)
- },
- // 删除
- deleteHandle(id) {
- this.$confirm('确定要删除该车间吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.dataListLoading = true
- let ids = []
- ids.push(id)
- // 调用删除接口
- remove(ids).then(({ data }) => {
- this.dataListLoading = false
- if (data && data.code === '200') {
- this.$message.success('删除成功')
- this.getDataList()
- } else {
- this.$message.error(data && data.msg ? data.msg : '删除失败')
- }
- }).catch(() => {
- this.dataListLoading = false
- })
- }).catch(() => { })
- },
- }
- }
- </script>
- <style scoped></style>
|