| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <template>
- <div>
- <!-- 数据表格 -->
- <ele-pro-table
- ref="table"
- :columns="columns"
- :datasource="datasource"
- height="calc(100vh - 265px)"
- full-height="calc(100vh - 116px)"
- tool-class="ele-toolbar-form"
- cache-key="systemOrgUserTable"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <item-search @search="reload"> </item-search>
- </template>
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- @click="openEdit(row)"
- >
- 编辑
- </el-link>
- <el-link
- v-if="row.loginName"
- type="primary"
- :underline="false"
- icon="el-icon-unlock"
- @click="toUnBind(row)"
- >
- 克隆
- </el-link>
- <el-popconfirm
- class="ele-action"
- title="确定要删除此物品?"
- @confirm="remove(row)"
- >
- <template v-slot:reference>
- <el-link type="danger" :underline="false" icon="el-icon-delete">
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- </div>
- </template>
- <script>
- import ItemSearch from './item-search.vue';
- // import {
- // getUserPage,
- // removePersonnel,
- // unbindLoginName
- // } from '@/api/system/organization';
- import { getList, removeItem } from '@/api/classifyManage/itemInformation';
- export default {
- components: { ItemSearch },
- props: {
- // 机构id
- organizationId: [Number, String],
- // 全部机构
- organizationList: Array,
- current: {
- type: Object,
- default: () => ({})
- }
- },
- data () {
- return {};
- },
- computed: {
- // 表格列配置
- columns () {
- const privateColumn = [];
- if (!['8', '1', '2', '5', '6', '7'].includes(this.current?.type)) {
- privateColumn.push({
- prop: 'brandNum',
- label: '牌号',
- showOverflowTooltip: true
- });
- }
- if (!['3'].includes(this.current?.type)) {
- privateColumn.push({
- prop: 'modelType',
- label: '型号',
- showOverflowTooltip: true
- });
- }
- if (!['3', '4'].includes(this.current?.type)) {
- privateColumn.push({
- prop: 'specification',
- label: '规格',
- showOverflowTooltip: true
- });
- }
- return [
- {
- columnKey: 'index',
- type: 'index',
- width: 45,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- prop: 'informationCode',
- label: '物品编码',
- showOverflowTooltip: true
- },
- {
- prop: 'informationName',
- label: '物品名称',
- showOverflowTooltip: true
- },
- {
- prop: 'classificationCode',
- label: '物品类型',
- showOverflowTooltip: true
- },
- ...privateColumn,
- {
- prop: 'measuringUnit',
- label: '计量单位',
- sortable: 'custom',
- showOverflowTooltip: true
- },
- {
- prop: 'packingUnit',
- label: '包装单位',
- align: 'center'
- },
- {
- prop: 'classificationUrl',
- label: '分类',
- showOverflowTooltip: true
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 200,
- align: 'left',
- resizable: false,
- slot: 'action'
- }
- ];
- }
- },
- methods: {
- /* 表格数据源 */
- datasource ({ page, limit, where }) {
- return getList({
- ...where,
- pageNum: page,
- size: limit
- });
- },
- /* 刷新表格 */
- reload (where) {
- this.$refs.table.reload({ pageNum: 1, where: where });
- },
- /* 显示编辑 */
- openEdit (row) {},
- // 解除绑定
- toUnBind (row) {
- const loading = this.$loading({ lock: true });
- unbindLoginName(row.id)
- .then((res) => {
- loading.close();
- this.$message.success('解绑成功');
- this.reload();
- })
- .catch((e) => {
- loading.close();
- this.$message.error(e.message);
- });
- },
- /* 删除 */
- remove (row) {
- const loading = this.$loading({ lock: true });
- removeItem(id).then((msg) => {
- loading.close();
- this.$message.success(msg);
- this.reload();
- });
- },
- /* 更改状态 */
- editStatus (row) {
- const loading = this.$loading({ lock: true });
- updateUserStatus(row.userId, row.status)
- .then((msg) => {
- loading.close();
- this.$message.success(msg);
- })
- .catch((e) => {
- loading.close();
- row.status = !row.status ? 1 : 0;
- this.$message.error(e.message);
- });
- }
- },
- watch: {
- // 监听机构id变化
- current: {
- handler () {
- console.log(this.current);
- this.reload();
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped></style>
|