Blame view

src/views/resource/scrapGoodsStepList.vue 7.4 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
325bf296   wuxw   测试完成采购流程
2
3
4
5
6
7
8
9
10
11
12
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
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
148
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
180
181
182
183
184
185
186
187
188
189
190
    <div class="scrap-goods-step-container">
      <el-card class="box-card">
        <div slot="header" class="flex justify-between">
          <span>{{ $t('viewResourceMyGoodsInfo.goodsInfo') }}</span>
          <div class="action-buttons">
            <el-button type="primary" size="small" @click="handleGoBack">
              <i class="el-icon-close"></i>
              {{ $t('viewResourceMyGoodsInfo.back') }}
            </el-button>
            <el-button type="primary" size="small" @click="handleOpenSelectModal">
              <i class="el-icon-search"></i>
              {{ $t('viewResourceMyGoodsInfo.selectGoods') }}
            </el-button>
          </div>
        </div>
  
        <el-table :data="form.resourceStores" border style="width: 100%">
          <el-table-column prop="resName" :label="$t('viewResourceMyGoodsInfo.goodsName')" align="center" />
          <el-table-column prop="resCode" :label="$t('viewResourceMyGoodsInfo.goodsCode')" align="center" />
          <el-table-column :label="$t('viewResourceMyGoodsInfo.goodsType')" align="center">
            <template slot-scope="scope">
              {{ scope.row.parentRstName || '-' }} > {{ scope.row.rstName || '-' }}
            </template>
          </el-table-column>
          <el-table-column prop="isFixedName" :label="$t('viewResourceMyGoodsInfo.isFixedGoods')" align="center" />
          <el-table-column :label="$t('viewResourceMyGoodsInfo.goodsStock')" align="center">
            <template slot-scope="scope">
              {{ scope.row.stock }}{{ scope.row.unitCodeName }}
            </template>
          </el-table-column>
          <el-table-column :label="$t('viewResourceMyGoodsInfo.miniStock')" align="center">
            <template slot-scope="scope">
              {{ scope.row.miniStock }}{{ scope.row.miniUnitCodeName }}
            </template>
          </el-table-column>
          <el-table-column :label="$t('viewResourceMyGoodsInfo.lossQuantity')" align="center">
            <template slot-scope="scope">
              <el-input-number v-model="scope.row.giveQuantity" :min="0" :max="parseFloat(scope.row.miniStock)"
                :precision="2" controls-position="right" style="width: 120px">
              </el-input-number>
              {{ scope.row.miniUnitCodeName }}
            </template>
          </el-table-column>
          <el-table-column :label="$t('viewResourceMyGoodsInfo.usageType')" align="center">
            <template slot-scope="scope">
              <el-select v-model="scope.row.state" style="width: 100%">
                <el-option :label="$t('viewResourceMyGoodsInfo.selectUsageType')" value=""></el-option>
                <el-option :label="$t('viewResourceMyGoodsInfo.scrapRecycle')" value="1001"></el-option>
                <el-option :label="$t('viewResourceMyGoodsInfo.publicLoss')" value="3003"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column :label="$t('viewResourceMyGoodsInfo.remark')" align="center">
            <template slot-scope="scope">
              <el-input v-model="scope.row.purchaseRemark" :placeholder="$t('viewResourceMyGoodsInfo.requiredRemark')">
              </el-input>
            </template>
          </el-table-column>
          <el-table-column :label="$t('viewResourceMyGoodsInfo.operation')" align="center">
            <template slot-scope="scope">
              <el-button type="danger" size="mini" @click="handleRemoveItem(scope.row.resId, scope.$index)">
                <i class="el-icon-delete"></i>
                {{ $t('viewResourceMyGoodsInfo.remove') }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
  
      <el-row>
        <el-col :span="24">
          <el-card class="box-card">
            <div slot="header" class="flex justify-between">
              <span>{{ $t('scrapGoodsStep.lossDescription') }}</span>
            </div>
            <el-form :model="form" label-width="120px">
              <el-form-item :label="$t('scrapGoodsStep.lossDescription')">
                <el-input type="textarea" v-model="form.remark" :placeholder="$t('scrapGoodsStep.requiredRemark')"
                  :rows="4">
                </el-input>
              </el-form-item>
            </el-form>
          </el-card>
        </el-col>
      </el-row>
  
      <el-row>
        <el-col :span="22" :offset="2">
          <div class="action-buttons">
            <el-button type="primary" @click="handleSubmit">
              {{ $t('scrapGoodsStep.submit') }}
            </el-button>
          </div>
        </el-col>
      </el-row>
      <choose-resource-staff ref="chooseResourceStaff" @setSelectResourceStores="handleSetSelectedStores">
      </choose-resource-staff>
    </div>
    
  </template>
  
  <script>
  import { saveAllocationUserStorehouse } from '@/api/resource/scrapGoodsStepApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  import ChooseResourceStaff from '@/components/resource/chooseResourceStaff'
  
  export default {
    name: 'ScrapGoodsStepList',
    components: {
      ChooseResourceStaff
  
    },
    data() {
      return {
        form: {
          resourceStores: [],
          remark: '',
          communityId: '',
          acceptUserId: '',
          acceptUserName: '',
          flag: '1'
        }
      }
    },
    created() {
      this.form.communityId = getCommunityId()
    },
    methods: {
      handleGoBack() {
        this.$router.go(-1)
      },
      handleNotify(goodsInfo) {
        this.form.resourceStores = goodsInfo
      },
      handleOpenSelectModal() {
        this.$refs.chooseResourceStaff.open()
      },
      handleSetSelectedStores(resourceStores) {
        this.form.resourceStores = resourceStores.map(item => {
          return {
            ...item,
            state: '',
            purchaseRemark: '',
            giveQuantity: 0
          }
        })
      },
      handleRemoveItem(resId, index) {
        this.form.resourceStores.splice(index, 1)
        this.$refs.chooseResourceStaff.removeSelectedItem(resId)
      },
      handleSubmit() {
        if (this.form.resourceStores.length === 0) {
          this.$message.error(this.$t('scrapGoodsStep.selectGoodsFirst'))
          return
        }
  
        if (!this.form.remark) {
          this.$message.error(this.$t('scrapGoodsStep.requiredRemark'))
          return
        }
  
        // 校验商品信息
        for (const item of this.form.resourceStores) {
          if (!item.giveQuantity || parseFloat(item.giveQuantity) <= 0) {
            this.$message.error(this.$t('scrapGoodsStep.requiredQuantity'))
            return
          }
  
          if (parseFloat(item.giveQuantity) > parseFloat(item.miniStock)) {
            this.$message.error(`${item.resName} ${this.$t('scrapGoodsStep.stockNotEnough')}`)
            return
          }
  
          if (!item.state) {
            this.$message.error(this.$t('scrapGoodsStep.requiredUsageType'))
            return
          }
  
          if (!item.purchaseRemark) {
            this.$message.error(this.$t('scrapGoodsStep.requiredNote'))
            return
          }
        }
  
        saveAllocationUserStorehouse(this.form)
          .then(response => {
            if (response.code === 0) {
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
191
              this.$message.success(this.$t('common.operationSuccess'))
325bf296   wuxw   测试完成采购流程
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
              this.$router.push('/resource/myResourceStoreManage')
            } else {
              this.$message.error(response.msg)
            }
          })
          .catch(error => {
            this.$message.error(this.$t('scrapGoodsStep.submitFailed'))
            console.error(error)
          })
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .scrap-goods-step-container {
    padding: 20px;
  
    .box-card {
      margin-bottom: 20px;
    }
  
    .action-buttons {
      text-align: right;
      margin-bottom: 20px;
    }
  }
  </style>