Blame view

src/views/resource/allocationStorehouseEnterList.vue 6.72 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
9c311762   wuxw   工作办理测试中
2
3
4
5
6
7
8
9
    <div class="allocation-storehouse-enter-container">
      <el-card>
        <div slot="header" class="flex justify-between">
          <span>{{ $t('allocationStorehouseEnter.title') }}</span>
        </div>
  
        <el-row :gutter="20">
          <el-col :span="24">
9c311762   wuxw   工作办理测试中
10
              <el-table :data="allocationStorehouseEnterInfo.resourceStores" border style="width: 100%"
19bafb73   wuxw   v1.9 优化采购相关bug
11
12
                v-loading="loading"  @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55" align="center">
9c311762   wuxw   工作办理测试中
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
                </el-table-column>
                <el-table-column prop="parentRstName" :label="$t('allocationStorehouseEnter.resourceType')"
                  align="center">
                  <template slot-scope="scope">
                    {{ scope.row.parentRstName }} > {{ scope.row.rstName }}
                  </template>
                </el-table-column>
                <el-table-column prop="resName" :label="$t('allocationStorehouseEnter.resourceName')"
                  align="center"></el-table-column>
                <el-table-column prop="specName" :label="$t('allocationStorehouseEnter.specification')" align="center">
                  <template slot-scope="scope">
                    {{ scope.row.specName || '-' }}
                  </template>
                </el-table-column>
                <el-table-column prop="resCode" :label="$t('allocationStorehouseEnter.resourceCode')"
                  align="center"></el-table-column>
                <el-table-column prop="isFixedName" :label="$t('allocationStorehouseEnter.fixedResource')"
                  align="center"></el-table-column>
                <el-table-column
                  :label="allocationStorehouseEnterInfo.applyType == '10000' || allocationStorehouseEnterInfo.applyType == '30000' ? $t('allocationStorehouseEnter.transferredWarehouse') : $t('allocationStorehouseEnter.returnPerson')"
                  align="center">
                  <template slot-scope="scope">
                    {{ allocationStorehouseEnterInfo.applyType == '10000' || allocationStorehouseEnterInfo.applyType ==
                      '30000' ? scope.row.shaName : allocationStorehouseEnterInfo.startUserName }}
                  </template>
                </el-table-column>
                <el-table-column prop="shaName" :label="$t('allocationStorehouseEnter.originalWarehouse')"
                  align="center"></el-table-column>
                <el-table-column prop="shzName" :label="$t('allocationStorehouseEnter.targetWarehouse')"
                  align="center"></el-table-column>
                <el-table-column
                  :label="$t('allocationStorehouseEnter.originalStock') + '(' + (allocationStorehouseEnterInfo.applyType == '30000' ? $t('allocationStorehouseEnter.targetWarehouse') : $t('allocationStorehouseEnter.transferredWarehouse')) + ')'"
                  align="center">
                  <template slot-scope="scope">
                    {{ scope.row.originalStock }}{{ scope.row.unitCodeName }}
                  </template>
                </el-table-column>
                <el-table-column prop="stock" :label="$t('allocationStorehouseEnter.transferQuantity')" align="center">
                  <template slot-scope="scope">
                    {{ scope.row.stock }}{{ scope.row.applyType == 20000 ? scope.row.miniUnitCodeName :
                      scope.row.unitCodeName }}
                  </template>
                </el-table-column>
                <el-table-column :label="$t('allocationStorehouseEnter.actualQuantity')" align="center">
                  <template slot-scope="scope">
                    <el-input v-model.number="scope.row.quantity" type="number"
                      :placeholder="$t('allocationStorehouseEnter.quantityPlaceholder')" style="width: 150px"></el-input>
                  </template>
                </el-table-column>
              </el-table>
9c311762   wuxw   工作办理测试中
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
          </el-col>
        </el-row>
  
        <el-row :gutter="20" style="margin-top: 20px">
          <el-col :span="24" style="text-align: right">
            <el-button type="primary" @click="handleSubmit">
              <i class="el-icon-check"></i>
              {{ $t('allocationStorehouseEnter.submit') }}
            </el-button>
          </el-col>
        </el-row>
      </el-card>
    </div>
  </template>
  
  <script>
  import { listAllocationStorehouses, allocationStoreEnter } from '@/api/resource/allocationStorehouseEnterApi'
  
  export default {
    name: 'AllocationStorehouseEnterList',
    data() {
      return {
        loading: false,
        allocationStorehouseEnterInfo: {
          resourceStores: [],
          applyId: '',
          taskId: '',
          selectResIds: []
        }
      }
    },
    created() {
      this.allocationStorehouseEnterInfo.applyId = this.$route.query.applyId
      this.allocationStorehouseEnterInfo.taskId = this.$route.query.taskId
      this.listAllocationStorehouseApply()
    },
    methods: {
      async listAllocationStorehouseApply() {
        try {
          this.loading = true
          const params = {
            page: 1,
            row: 100,
            applyId: this.allocationStorehouseEnterInfo.applyId
          }
          const { data } = await listAllocationStorehouses(params)
          this.allocationStorehouseEnterInfo.resourceStores = data
        } catch (error) {
          this.$message.error(this.$t('allocationStorehouseEnter.fetchError'))
        } finally {
          this.loading = false
        }
      },
      handleSelectionChange(val) {
        this.allocationStorehouseEnterInfo.selectResIds = val.map(item => item.resId)
      },
      async handleSubmit() {
        // Validation
        const selectedItems = this.allocationStorehouseEnterInfo.resourceStores.filter(item =>
          this.allocationStorehouseEnterInfo.selectResIds.includes(item.resId)
        )
  
        if (selectedItems.length === 0) {
          this.$message.warning(this.$t('allocationStorehouseEnter.selectItemsWarning'))
          return
        }
  
        let hasError = false
        selectedItems.forEach(item => {
          if (!item.quantity || parseFloat(item.quantity) <= 0) {
            hasError = true
            return
          }
          item.quantity = parseFloat(item.quantity)
        })
  
        if (hasError) {
          this.$message.warning(this.$t('allocationStorehouseEnter.quantityWarning'))
          return
        }
  
        this.allocationStorehouseEnterInfo.resourceStores = selectedItems
  
        try {
          await allocationStoreEnter(this.allocationStorehouseEnterInfo)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
148
          this.$message.success(this.$t('common.operationSuccess'))
9c311762   wuxw   工作办理测试中
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
          this.$router.go(-1)
        } catch (error) {
          this.$message.error(error.message || this.$t('allocationStorehouseEnter.submitError'))
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .allocation-storehouse-enter-container {
    padding: 20px;
  
    .el-card {
      margin-bottom: 20px;
    }
  
    .clearfix {
  
      &:before,
      &:after {
        display: table;
        content: "";
      }
  
      &:after {
        clear: both;
      }
    }
  }
  </style>