| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- <template>
- <div class="ele-body">
- <el-card shadow="never">
- <search
- ref="search"
- @search="search"
- :options_groupId="dict.groupId"
- :options_factory="dict.factory"
- ></search>
- <ele-pro-table
- ref="table"
- :columns="columns"
- height="calc(100vh - 350px)"
- :datasource="datasource"
- :page-size="pageSize"
- @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('add')"
- v-if="$hasPermission('main:factoryarea:saveOrUpdate')"
- >
- 添加
- </el-button>
- </template>
- <template v-slot:parent="{ row }">
- {{ showgfactory(row, 2) }}
- </template>
- <template v-slot:factory="{ row }">
- {{ showgfactory(row, 1) }}
- </template>
- <template v-slot:enabled="{ row }">
- {{ dict.enabled[row.enabled] }}
- </template>
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- @click="openEdit('copy', row)"
- v-if="$hasPermission('main:factoryarea:saveOrUpdate')"
- >
- 复制
- </el-link>
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- @click="openEdit('edit', row)"
- v-if="$hasPermission('main:factoryarea:saveOrUpdate')"
- >
- 修改
- </el-link>
- <el-popconfirm
- class="ele-action"
- title="确定要删除此角色吗?"
- @confirm="remove(row)"
- v-if="$hasPermission('main:factoryarea: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>
- <edit
- ref="edit"
- @done="done"
- :options_groupId="dict.groupId"
- :options_factory="dict.factory"
- ></edit>
- </div>
- </template>
- <script>
- import tabMixins from '@/mixins/tableColumnsMixin';
- import search from './components/search.vue';
- import edit from './components/edit.vue';
- import { getFactoryarea, deletefactoryarea } from '@/api/factoryModel';
- import { listOrganizations } from '@/api/system/organization';
- export default {
- mixins: [tabMixins],
- components: {
- search,
- edit
- },
- data () {
- return {
- columns: [
- {
- width: 45,
- type: 'index',
- columnKey: 'index',
- align: 'center'
- },
- {
- prop: 'code',
- label: '厂房编码'
- },
- {
- label: '厂房名称',
- prop: 'name'
- },
- {
- label: '状态',
- prop: 'enabled',
- slot: 'enabled'
- },
- {
- label: '联系方式',
- prop: 'extInfo.phone'
- },
- {
- label: '工厂编码',
- prop: 'parentCode',
- slot: 'parent'
- },
- {
- label: '所属工厂',
- prop: 'extInfo.parentId',
- slot: 'factory'
- },
- {
- label: '所属区域',
- prop: 'areaName',
- },
- {
- label: '省/市/区',
- prop: 'extInfo.location'
- },
- {
- label: '详细地址',
- prop: 'extInfo.locationDetail'
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 220,
- align: 'center',
- resizable: false,
- slot: 'action',
- showOverflowTooltip: true
- }
- ],
- dict: {
- groupId: [],
- factory: [],
- enabled: {
- 1: '生效',
- 0: '未生效'
- }
- },
- pageSize: this.$store.state.tablePageSize,
- cacheKeyUrl: 'd4c09700-factoryModel-plant'
- };
- },
- created () {
- this.getGs();
- this.getFactoryarea();
- },
- methods: {
- datasource ({ page, where, limit }) {
- return getFactoryarea({
- ...where,
- pageNum: page,
- size: limit,
- type: 2
- });
- },
- search (where) {
- this.$refs.table.reload({
- where: where,
- page: 1
- });
- },
- openEdit (type, row) {
- this.$refs.edit.open(type, row);
- },
- // 获取公司数据
- getGs () {
- listOrganizations().then((list) => {
- console.log(list);
- this.dict.groupId = list;
- });
- },
- // 回显工厂名称
- showgfactory (row, type) {
- let result = row.parent.find((n) => n.id == row.parentId);
- if (result && type == 1) {
- return result.name;
- } else if(result && type == 2) {
- return result.code;
- }
- else {
- return '';
- }
- },
- // 获取工厂数据
- getFactoryarea () {
- let par = {
- type: 1,
- size: 9999,
- enable:1
- };
- getFactoryarea(par).then((res) => {
- this.dict.factory = res.list;
- });
- },
- remove (row) {
- deletefactoryarea(row.id)
- .then((message) => {
- this.$message.success(message);
- this.done();
- })
- .catch((e) => {
- this.$message.error(e.message);
- });
- },
- done () {
- this.$refs.search.search();
- }
- }
- };
- </script>
|