Blame view

src/views/project/finance/pay/TrackEdit.vue 5.13 KB
1
2
3
4
5
<template>
  <template>
    <BasicDrawer
      @register="register"
      v-bind="$attrs"
6
      title="跟单编辑"
7
8
9
10
      width="30%"
      :isDetail="true"
      @ok="handleSubmit"
      :showDetailBack="false"
柏杨 authored
11
      @visible-change="handleShow"
12
13
14
15
16
      okText="保存"
      showFooter
      :destroyOnClose="true"
    >
      <div>
柏杨 authored
17
        <div style="font-size: 15px">生产科扣款金额¥</div>
柏杨 authored
18
        <a-input v-model:value="input1" placeholder="请输入" :disabled="status === 10" auto-size />
19
20
        <div style="margin: 16px 0"></div>
        <div style="font-size: 15px">扣款责任部门</div>
柏杨 authored
21
22
23
24
25
26
27
28
29
30
31
32
        <a-input
          v-model:value="deductDept"
          placeholder="请输入"
          :disabled="status === 10"
          auto-size
        />
        <!-- <a-select
          ref="select"
          style="width: 60%"
          v-model:value="selectedProductionDepartment"
          :options="productionDepartmentOptions"
        /> -->
柏杨 authored
33
34
35
36
37
38
        <!-- <a-select
          ref="select"
          style="width: 100%"
          v-model:value="productionDepartment"
          :options="productDepartmentOptions"
        /> -->
39
40
41
42
43
        <div style="margin: 16px 0"></div>
        <div>上传扣款单</div
        ><a-space direction="vertical" style="width: 100%" size="large">
          <a-upload
            v-model:file-list="fileList"
44
            :beforeUpload="beforeUpload"
45
46
            list-type="picture"
            :max-count="1"
柏杨 authored
47
            :disabled="status === 10"
48
49
            :action="updateDeductUrl"
            @change="handleChange"
50
          >
51
            <a-button> 上传扣款单 </a-button>
52
53
54
55
56
57
58
59
60
61
62
63
          </a-upload>
        </a-space>
      </div>
      <!-- <template #titleToolbar> <a-button type="primary"> 申请编辑权限 </a-button></template> -->
      <template #appendFooter>
        <!-- <a-button type="primary" @click="onGoCheckDetail"> 申请权限</a-button> -->
      </template>
    </BasicDrawer>
  </template>
</template>
<script lang="ts" setup>
  import { BasicDrawer, useDrawerInner } from '@/components/Drawer';
柏杨 authored
64
  import { defineComponent, ref, computed, unref, toRaw, reactive, onMounted } from 'vue';
65
66
67
  import { getEmailList } from '/@/api/sys/config';
  import { UploadOutlined } from '@ant-design/icons-vue';
  import type { UploadProps } from 'ant-design-vue';
68
  import { updateDeductInfo } from '@/api/project/invoice';
69
  import { useMessage } from '/@/hooks/web/useMessage';
柏杨 authored
70
71
  import { useOrderInfo } from '/@/hooks/component/order';
  import { useOrderStoreWithOut } from '/@/store/modules/order';
72
73
  const emit = defineEmits(['success']);
74
  const fileList = ref<UploadProps['fileList']>([]);
柏杨 authored
75
76
77
78
79
80
81
  // const orderStore = useOrderStoreWithOut();
  // const { productionDepartment: productionDepartmentOptions } = useOrderInfo(orderStore);
  // console.log(productionDepartmentOptions.value, '565656565665orderStore');
  // onMounted(() => {
  //   const { productionDepartment } = useOrderInfo(orderStore);
  //   console.log(productionDepartment.value, '565656565665orderStore1');
  // });
柏杨 authored
82
83
84
85
  const orderStore = useOrderStoreWithOut();
  const { productionDepartment: productDepartmentOptions } = useOrderInfo(orderStore);
  const productionDepartment = ref();
  const input1 = ref(0);
86
87
88
  const deductUrl = ref();
  const id = ref();
  const checkNo = ref();
柏杨 authored
89
  const deductDept = ref();
柏杨 authored
90
91
92
93
  const uploadUrl = ref('http://47.104.8.35:80/api/localStorage/upload_file_oss?name=');
  const updateDeductUrl = ref('http://47.104.8.35:80/api/localStorage/upload_file_oss?name=');
  // const uploadUrl = ref('');
  // const updateDeductUrl = ref('');
94
  const deductUrlOld = ref();
柏杨 authored
95
  const selectedProductionDepartment = ref(); // 新增: 用于存储选中的生产科
96
97
  const { createMessage } = useMessage();
  const { error } = createMessage;
柏杨 authored
98
  const status = ref();
99
100

  const [register, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => {
柏杨 authored
101
    status.value = data.data.status;
102
103
104
105
106
    id.value = data.data.id;
    checkNo.value = data.data.checkNo;
    input1.value = data.data.deductAmount;
    deductDept.value = data.data.deductDept;
    deductUrl.value = data.data.deductUrl;
107
    deductUrlOld.value = data.data.deductUrl;
108
  });
109
110
111
112
113
  function handleChange(info) {
    if (info.file.status == 'done') {
      updateDeductUrl.value = info.file.response.data.fileUrl;
      deductUrl.value = updateDeductUrl.value;
    }
114
115
116
117
    if (info.fileList.length == 0) {
      info.file = null;
      deductUrl.value = '';
    }
118
119
120
  }
  function beforeUpload(info) {
    updateDeductUrl.value = uploadUrl.value + info.name;
121
  }
柏杨 authored
122
  function handleShow() {
柏杨 authored
123
124
125
126
127
    // input1.value = '';
    // deductUrl.value = '';
    // deductDept.value = '';
    // updateDeductUrl.value = '';
    // fileList.value = [];
柏杨 authored
128
  }
129
130
  //完成编辑
  async function handleSubmit() {
柏杨 authored
131
    if (!input1.value || !deductDept.value) {
132
133
      error('选项不能为空');
    } else {
柏杨 authored
134
135
136
137
138
139
140
141
142
143
144
      await updateDeductInfo({
        id: id.value,
        checkNo: checkNo.value,
        deductAmount: input1.value,
        deductDept: deductDept.value,
        deductUrl: deductUrl.value,
      });
      // productionDepartment: selectedProductionDepartment.value,
      fileList.value = [];
      emit('success');
      closeDrawer();
145
    }
146
147
  }
</script>