| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <template>
- <div class="ele-body">
- <el-card shadow="never">
- <!-- 搜索表单 -->
- <user-search
- @search="reload"
- :flist="fList"
- :categoryTypes="categoryTypes"
- />
- <!-- 数据表格 -->
- <ele-pro-table
- ref="table"
- :columns="columns"
- :datasource="datasource"
- :selection.sync="selection"
- v-loading="loading"
- row-key="code"
- :pageSize="this.$store.state.tablePageSize"
- @columns-change="handleColumnChange"
- :cache-key="cacheKeyUrl"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="openEdit()"
- v-if="$hasPermission('main:workcenter:save')"
- >
- 新建
- </el-button>
- </template>
- <template v-slot:factoryId="{ row }">
- {{ checkfactoryId(row.factoryId) }}
- </template>
- <template v-slot:categoryType="{ row }">
- {{ checkcategoryType(row.categoryType) }}
- </template>
- <!-- <template v-slot:leaderUserId="{ row }">
- {{ checkleaderUserId(row.leaderUserId) }}
- </template> -->
- <!-- 状态列 -->
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- @click="openEdit(row,'copy')"
- v-if="$hasPermission('main:workcenter:save')"
- >
- 复制
- </el-link>
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- @click="openEdit(row,'edit')"
- v-if="$hasPermission('main:workcenter:update')"
- >
- 修改
- </el-link>
- <el-popconfirm
- class="ele-action"
- title="确定要删除当前工序吗?"
- @confirm="remove(row)"
- v-if="$hasPermission('main:workcenter:delete')"
- >
- <template v-slot:reference>
- <el-link type="danger" :underline="false" icon="el-icon-delete">
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- </el-card>
- <!-- 编辑弹窗 -->
- <user-edit
- :visible.sync="showEdit"
- :flist="fList"
- :data="current"
- :userList="userList"
- :categoryTypes="categoryTypes"
- @done="reload"
- ref="userEdit"
- />
- <!-- 导入弹窗 -->
- </div>
- </template>
- <script>
- import tabMixins from '@/mixins/tableColumnsMixin';
- import UserSearch from './components/user-search.vue';
- import UserEdit from './components/user-edit.vue';
- import work from '@/api/technology/work';
- import route from '@/api/technology/route';
- export default {
- name: 'technologyWork',
- mixins: [tabMixins],
- components: {
- UserSearch,
- UserEdit
- },
- data() {
- return {
- // 表格列配置
- columns: [
- {
- prop: 'factoryId',
- label: '所属工厂',
- slot: 'factoryId',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110
- },
- {
- prop: 'code',
- label: '工作中心编码',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110
- },
- {
- prop: 'name',
- label: '工作中心名称',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110
- },
- {
- prop: 'categoryType',
- label: '工作中心类别',
- slot: 'categoryType',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- prop: 'leaderUserName',
- label: '负责人',
- // slot: 'leaderUserId',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 220,
- align: 'center',
- resizable: false,
- slot: 'action',
- showOverflowTooltip: true
- }
- ],
- categoryTypes: [
- { label: '设备', value: 0 },
- { label: '设备组', value: 1 },
- { label: '人工', value: 2 },
- { label: '人工组', value: 3 },
- { label: '生产线', value: 4 },
- { label: '委外生产', value: 5 }
- ],
- // 厂房列表
- fList: [],
- // 人员列表
- userList: [],
- // 表格选中数据
- selection: [],
- // 当前编辑数据
- current: null,
- // 是否显示编辑弹窗
- showEdit: false,
- // 是否显示导入弹窗
- showImport: false,
- loading: false,
- cacheKeyUrl: '439a8ef9-technology-work'
- };
- },
- created() {
- this.getfLise();
- this.getUserPage();
- },
- methods: {
- /*回显工厂 */
- checkfactoryId(id) {
- let obj = this.fList.find((f) => f.id == id);
- return obj?.name;
- },
- /*回显类别 */
- checkcategoryType(value) {
- return this.categoryTypes.find((f) => f.value == value).label;
- },
- /*回显负责人 */
- checkleaderUserId(id) {
- let obj = this.userList.find((f) => f.id == id);
- return obj?.name;
- },
- /*人员列表 */
- async getUserPage() {
- const res = await work.getUserPage();
- this.userList = res.list;
- },
- /*厂房列表 */
- async getfLise() {
- const res = await route.Flist({
- pageNum: 1,
- size: -1,
- type: 1
- });
- this.fList = res.list;
- },
- /* 表格数据源 */
- async datasource({ page, limit, where, order }) {
- const res = await work.list({
- ...where,
- ...order,
- pageNum: page,
- size: limit
- });
- return res;
- },
- /* 刷新表格 */
- reload(where) {
- this.$refs.table.reload({ page: 1, where: where });
- },
- /* 打开编辑弹窗 */
- openEdit(row,type) {
- this.current = row;
- if(this.current){
- this.current.type=type
- }
-
- this.showEdit = true;
- this.$refs.userEdit.$refs.form &&
- this.$refs.userEdit.$refs.form.clearValidate();
- },
- /* 打开导入弹窗 */
- openImport() {
- this.showImport = true;
- },
- /* 删除 */
- remove(row) {
- // const loading = this.$loading({ lock: true });
- this.loading = true;
- work
- .delete([row.id])
- .then((msg) => {
- // loading.close();
- this.loading = false;
- this.$message.success('删除' + msg);
- this.reload();
- })
- .catch((e) => {
- loading.close();
- // this.$message.error(e.message);
- });
- },
- /* 批量删除 */
- removeBatch() {
- if (!this.selection.length) {
- this.$message.error('请至少选择一条数据');
- return;
- }
- this.$confirm('确定要删除选中的工序吗?', '提示', {
- type: 'warning'
- })
- .then(() => {
- const loading = this.$loading({ lock: true });
- producetask
- .delete(this.selection.map((d) => d.id))
- .then((msg) => {
- loading.close();
- this.$message.success('删除' + msg);
- this.reload();
- })
- .catch((e) => {
- loading.close();
- // this.$message.error(e.message);
- });
- })
- .catch(() => {});
- }
- }
- };
- </script>
|