partsListModal.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <BasicModal
  3. v-bind="$attrs"
  4. @register="register"
  5. :title="modelRef.title"
  6. @visible-change="handleVisibleChange"
  7. @cancel="resetFields"
  8. @ok="handleSubmit"
  9. :min-height="0"
  10. >
  11. <div class="pt-2px pr-3px recoverPage">
  12. <div class="form_item"><div class="item_lable">维修单号:</div>{{modelRef.repairId}}</div>
  13. <div class="form_item"><div class="item_lable">维修工程师:</div>{{modelRef.repairManName}}</div>
  14. <BasicTable @register="registerTable" />
  15. <div class="tips">{{ modelRef.title == '备件出库'?'注:请按备件清单给维修工程师提供备件':'回收说明:完成维修,请回收废旧备件;取消维修,请回收新的备件 (自动恢复库存)。' }}</div>
  16. </div>
  17. </BasicModal>
  18. </template>
  19. <script lang="ts">
  20. import { defineComponent, ref, onMounted, h } from 'vue';
  21. import { BasicModal, useModalInner } from '/@/components/Modal';
  22. import { BasicTable, useTable, BasicColumn } from '/@/components/Table';
  23. import { useMessage } from '/@/hooks/web/useMessage';
  24. import { partInfo, partRecovery, partOut } from '/@/api/spares';
  25. import { useI18n } from '/@/hooks/web/useI18n';
  26. const { t } = useI18n();
  27. export default defineComponent({
  28. components: { BasicModal, BasicTable },
  29. props: {
  30. userData: { type: Object },
  31. },
  32. emits: ['update'],
  33. setup(_, { emit }) {
  34. const repairId = ref('')
  35. const type = ref(0)
  36. const modelRef = ref({
  37. title:'设备入库',
  38. repairId:'0000123',
  39. repairManName:'',
  40. });
  41. const columns: BasicColumn[] = [
  42. {
  43. title: '备件编号',
  44. dataIndex: 'partNum',
  45. width: 100,
  46. },{
  47. title: '备件名称',
  48. dataIndex: 'partName',
  49. width: 100,
  50. },{
  51. title: '数量',
  52. dataIndex: 'partCount',
  53. width: 100,
  54. },
  55. ]
  56. const [registerTable, { reload }] = useTable({
  57. api: partInfo,
  58. searchInfo: {repairId:repairId,type:type},
  59. immediate:false,
  60. pagination:false,
  61. columns,
  62. });
  63. const { createMessage, createConfirm } = useMessage();
  64. onMounted(() => {});
  65. let addListFunc = () => {};
  66. const [register, { closeModal }] = useModalInner((data) => {
  67. // console.log(data);
  68. data && onDataReceive(data);
  69. });
  70. function onDataReceive(data) {
  71. type.value = data.status == 50?0:1
  72. modelRef.value.title = data.status == 50?'备件出库':'备件回收';
  73. repairId.value = data.repairId
  74. modelRef.value.repairId = data.repairId;
  75. modelRef.value.repairManName = data.repairManName;
  76. reload()
  77. }
  78. function handleVisibleChange() {}
  79. const handleSubmit = async () => {
  80. let api = modelRef.value.title == '备件出库'?partOut:partRecovery
  81. createConfirm({
  82. iconType: 'warning',
  83. title: () => h('span', '温馨提示'),
  84. content: `确定要提交${modelRef.value.title == '备件出库'?'出库':'备件回收'}吗?`,
  85. onOk: async () => {
  86. await api({repairId:modelRef.value.repairId})
  87. createMessage.success(t('common.optSuccess'));
  88. closeModal();
  89. emit('update');
  90. },
  91. });
  92. };
  93. return {
  94. register,
  95. modelRef,
  96. registerTable,
  97. handleVisibleChange,
  98. handleSubmit,
  99. addListFunc,
  100. t,
  101. };
  102. },
  103. });
  104. </script>
  105. <style lang="less" scoped>
  106. .recoverPage{
  107. .form_item{
  108. line-height: 30px;
  109. .item_lable{
  110. display: inline-block;
  111. width: 100px;
  112. text-align: right;
  113. }
  114. }
  115. }
  116. </style>