Ben Lin
2024-10-24 5a813f3b28f3cbf1db3a3657ccf83267c6e0d315
src/views/tigerprojects/mes/eng/route/components/PostProps.vue
@@ -1,10 +1,10 @@
<!--
 * @Description: file content
 * @Description: 工艺路线岗位资源维护
 * @Author: Ben Lin
 * @version: 
 * @Date: 2024-06-11 21:07:04
 * @LastEditors: your name
 * @LastEditTime: 2024-06-13 08:55:09
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-10-23 21:36:49
-->
<!--
 * @Description: 右侧属性面板控件 表单属性面板
@@ -13,20 +13,25 @@
  <div class="m-1">
    <BasicTable @register="registerTable">
      <template #toolbar>
        <a-button type="primary" @click="handleCreate" preIcon="add_02|svg" :size="size"> 新增 </a-button>
        <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),
        <TableAction
          :actions="[
            {
              icon: 'ant-design:delete-outlined',
              color: 'error',
              popConfirm: {
                title: '是否确认删除?',
                placement: 'left',
                confirm: handleDelete.bind(null, record),
              },
              name: '',
            },
          },
        ]" />
          ]"
        />
      </template>
    </BasicTable>
  </div>
@@ -34,135 +39,163 @@
  <GeneralModal @register="register" @success="handleSuccess"></GeneralModal>
</template>
<script lang="ts" setup>
import { notification } from 'ant-design-vue';
import { BasicTable, TableAction, useTable } from '/@/components/Table';
import { SizeType } from 'ant-design-vue/es/config-provider';
import { nextTick, onMounted, ref, unref, watch } from 'vue';
import { useModal } from '/@/components/Modal';
import GeneralModal from '/@/views/components/GeneralModal.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';
  import { notification } from 'ant-design-vue';
  import { BasicTable, TableAction, useTable } from '/@/components/Table';
  import { SizeType } from 'ant-design-vue/es/config-provider';
  import { nextTick, onMounted, ref, unref, watch } from 'vue';
  import { useModal } from '/@/components/Modal';
  import GeneralModal from '/@/views/components/GeneralModal.vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { DeleteWhere, getListByPage } from '/@/api/tigerapi/system';
  import { useRouteDesignState } from '../hooks/useRouteDesignState';
  import { SaveRouteNodePost, SaveWoRouteNodePost } from '/@/api/tigerapi/mes/router';
const { t } = useI18n();
const { routeConfig, mesRoute } = useRouteDesignState();
const size = ref<SizeType>('small');
const columns = [
  {
    title: '岗位名称',
    dataIndex: 'POST_NAME',
    key: 'POST_NAME',
    slots: { customRender: 'POST_NAME' },
  },
  {
    title: '岗位编码',
    dataIndex: 'POST_CODE',
    key: 'POST_CODE',
  },
];
  const { t } = useI18n();
  const { routeConfig, mesRoute } = useRouteDesignState();
  const size = ref<SizeType>('small');
  const columns = [
    {
      title: '岗位名称',
      dataIndex: 'POST_NAME',
      key: 'POST_NAME',
      slots: { customRender: 'POST_NAME' },
    },
    {
      title: '岗位编码',
      dataIndex: 'POST_CODE',
      key: 'POST_CODE',
    },
    {
      title: t('产线编码'),
      dataIndex: 'LINE_CODE',
      key: 'LINE_CODE',
    },
  ];
const [register, { openModal }] = useModal();
const [registerTable, { reload }] = useTable({
  title: '列表',
  api: getListByPage,
  searchInfo: { TABLE_NAME: 'V_MES_ROUTE_NODE_POST', NODE_ID: routeConfig.currentItem.ID },
  columns,
  useSearchForm: false,
  showTableSetting: false,
  bordered: true,
  showIndexColumn: false,
  pagination: { pageSize: 10 },
  actionColumn: {
    width: 80,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
  },
});
defineExpose({
  reload
});
// watch(
//   () => routeConfig.currentItem.ID,
//   (newVal, oldVal) => {
//     if (newVal != oldVal) {
//       nextTick(() => {
//         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',
    searchInfo: {TABLE_NAME: 'MES_POSITION'}
  const [register, { openModal }] = useModal();
  const [registerTable, { reload }] = useTable({
    title: '列表',
    api: getListByPage,
    searchInfo: routeConfig['isWorkOrder']
      ? { TABLE_NAME: 'V_MES_WO_NODE_POST', NODE_ID: routeConfig['currentItem'].ID }
      : { TABLE_NAME: 'V_MES_ROUTE_NODE_POST', NODE_ID: routeConfig['currentItem'].ID },
    columns,
    useSearchForm: false,
    showTableSetting: false,
    bordered: true,
    showIndexColumn: false,
    pagination: { pageSize: 10 },
    actionColumn: {
      width: 80,
      title: '操作',
      dataIndex: 'action',
      slots: { customRender: 'action' },
    },
  });
}
  defineExpose({
    reload,
  });
  // watch(
  //   () => routeConfig.currentItem.ID,
  //   (newVal, oldVal) => {
  //     if (newVal != oldVal) {
  //       nextTick(() => {
  //         reload();
  //       });
  //     }
  //   },
  //   { deep: true, immediate: true },
  // );
/**
* @description: 删除
  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,
        },
        {
          title: t('产线编码'),
          dataIndex: 'LINE_CODE',
          resizable: true,
          sorter: true,
          width: 180,
        },
      ],
      tableName: 'MES_POSITION',
      rowKey: 'POST_CODE',
      searchInfo: { TABLE_NAME: 'MES_POSITION' },
    });
  }
  /**
   * @description: 删除
   * @param {*} record
   * @return {*}
   */
function handleDelete(record: Recordable) {
  DeleteWhere(`POST_CODE = '${record.POST_CODE}' And NODE_ID = '${record.NODE_ID}'`, 'MES_ROUTE_NODE_POST').then((res) => {
    reload();
  });
}
/**
 * @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: '' });
  function handleDelete(record: Recordable) {
    let entityName = routeConfig['isWorkOrder'] ? 'MES_WO_NODE_POST' : 'MES_ROUTE_NODE_POST';
    DeleteWhere(
      `POST_CODE = '${record.POST_CODE}' And NODE_ID = '${record.NODE_ID}'`,
      entityName,
    ).then((res) => {
      reload();
    });
  }
  SaveRouteNodePost(eintity).then((res) => {
    reload();
  });
}
  /**
   * @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: '',
        WORK_ORDER: routeConfig['currentItem'].WORK_ORDER,
      });
    }
    if (routeConfig['isWorkOrder']) {
      SaveWoRouteNodePost(eintity).then((res) => {
        reload();
      });
    } else {
      SaveRouteNodePost(eintity).then((res) => {
        reload();
      });
    }
  }
</script>