Ben Lin
2024-06-12 da85b09c600ddcf4e5c8cad66012fa29a8252b39
src/views/tigerprojects/mes/eng/route/components/PostProps.vue
@@ -4,60 +4,158 @@
 * @version: 
 * @Date: 2024-06-11 21:07:04
 * @LastEditors: your name
 * @LastEditTime: 2024-06-12 10:11:05
 * @LastEditTime: 2024-06-12 23:04:02
-->
<!--
 * @Description: 右侧属性面板控件 表单属性面板
-->
<template>
  <div class="mt-3">
    <Button type="primary" @click="handleCreate" preIcon="add_02|svg" :size="size"> 新增 </Button>
    <a-table :columns="columns" :data-source="data" bordered>
      <template #name="{ text }">
      <a>{{ text }}</a>
    </template>
    </a-table>
    <BasicTable @register="registerTable">
      <template #toolbar>
        <a-button type="primary" @click="handleCreate" preIcon="add_02|svg" :size="size"> 新增 </a-button>
      </template>
      <template #action="{ record }">
        <TableAction :actions="[
          {
            icon: 'ant-design:delete-outlined',
            color: 'error',
            popConfirm: {
              title: '是否确认删除?',
              placement: 'left',
              confirm: handleDelete.bind(null, record),
            },
          },
        ]" />
      </template>
    </BasicTable>
  </div>
  <NormalModal @register="register" @success="handleSuccess"></NormalModal>
</template>
<script lang="ts" setup>
import { Table, notification } from 'ant-design-vue';
import { Button } from '/@/components/Button';
import { notification } from 'ant-design-vue';
import { BasicTable, TableAction, useTable } from '/@/components/Table';
import { SizeType } from 'ant-design-vue/es/config-provider';
import { ref } from 'vue';
import { onMounted, ref, unref, watch } from 'vue';
import { useModal } from '/@/components/Modal';
import NormalModal from '/@/views/components/NormalModal.vue';
import { useI18n } from '/@/hooks/web/useI18n';
import { DeleteEntity, DeleteWhere, SaveEntity, getEntity, getListByPage } from '/@/api/tigerapi/system';
import { useRouteDesignState } from '../hooks/useRouteDesignState';
import { SaveRouteNodePost } from '/@/api/tigerapi/mes/router';
const ATable = Table;
const { t } = useI18n();
const { routeConfig, mesRoute } = useRouteDesignState();
const size = ref<SizeType>('small');
const columns = [
  {
    title: 'Name',
    dataIndex: 'name',
    key: 'name',
    slots: { customRender: 'name' },
    title: '岗位名称',
    dataIndex: 'POST_NAME',
    key: 'POST_NAME',
    slots: { customRender: 'POST_NAME' },
  },
  {
    title: 'Age',
    dataIndex: 'age',
    key: 'age',
    title: '岗位编码',
    dataIndex: 'POST_CODE',
    key: 'POST_CODE',
  },
];
const data: DataItem[] = [];
for (let i = 0; i < 100; i++) {
  data.push({
    key: i,
    name: `Edrward ${i}`,
    age: 32,
    address: `London Park no. ${i}`,
const [register, { openModal }] = useModal();
const [registerTable, { reload }] = useTable({
  title: '列表',
  api: getListByPage,
  searchInfo: { TABLE_NAME: 'V_MES_ROUTE_NOE_POST', NODE_ID: routeConfig.currentItem.ID },
  columns,
  useSearchForm: false,
  showTableSetting: false,
  bordered: true,
  showIndexColumn: false,
  actionColumn: {
    width: 80,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
  },
});
// watch(
//   () => routeConfig.currentItem.ID,
//   (newVal, oldVal) => {
//     if (newVal != oldVal) {
//       reload();
//     }
//   },
//   { deep: true, immediate: true },
// );
onMounted(() => {
});
/**
 * @description: 新增方法
 * @return {*}
 */
function handleCreate() {
  openModal(true, {
    title: '岗位资源列表',
    schemas: [
      {
        field: 'POST_CODE',
        component: 'Input',
        label: '岗位资源编码',
        colProps: {
          span: 12,
        },
      },
    ],
    ItemColumns: [
      {
        title: t('岗位资源编码'),
        dataIndex: 'POST_CODE',
        resizable: true,
        sorter: true,
        width: 200,
      },
      {
        title: t('岗位资源名称'),
        dataIndex: 'POST_NAME',
        resizable: true,
        sorter: true,
        width: 180,
      },
    ],
    tableName: 'MES_POSITION',
    rowKey: 'POST_CODE',
  });
}
interface DataItem {
  key: number;
  name: string;
  age: number;
  address: string;
/**
* @description: 删除
   * @param {*} record
   * @return {*}
   */
function handleDelete(record: Recordable) {
  DeleteWhere(`POST_CODE = '${record.POST_CODE}'`, 'MES_ROUTE_NODE_POST').then((res) => {
    reload();
  });
}
function handleCreate() {}
/**
 * @description: 选择岗位资源成功返回方法
 * @param {*} d
 * @param {*} u
 * @return {*}
 */
function handleSuccess(d, u) {
  let codes = d.values.val.split(',');
  let eintity: any[] = [];
  var i;
  for (i = 0; i < codes.length; i++) {
    eintity.push({ NODE_ID: routeConfig.currentItem.ID, POST_CODE: codes[i], REMARK: '' });
  }
  SaveRouteNodePost(eintity).then((res) => {
    reload();
  });
}
</script>