Blame view

src/components/resource/chooseResourceStore4.vue 9.04 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
1cad66ad   wuxw   完成采购申请
2
3
4
    <el-dialog :title="$t('chooseResourceStore4.title')" :visible.sync="visible" width="80%" @close="handleClose">
      <div class="filter-container">
        <el-row :gutter="20">
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
5
          <el-col :span="4">
1cad66ad   wuxw   完成采购申请
6
7
8
9
10
11
12
            <el-select v-model="chooseResourceStoreInfo4.shId" disabled style="width:100%">
              <el-option value="" :label="$t('chooseResourceStore4.selectWarehouse')" />
              <el-option v-for="(item, index) in chooseResourceStoreInfo4.storehouses" :key="index" :label="item.shName"
                :value="item.shId" />
            </el-select>
          </el-col>
  
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
13
          <el-col :span="4">
1cad66ad   wuxw   完成采购申请
14
15
16
17
18
19
20
21
            <el-select v-model="chooseResourceStoreInfo4.parentRstId" @change="_listResourceStoreSonTypes"
              style="width:100%">
              <el-option value="" :label="$t('chooseResourceStore4.selectItemType')" />
              <el-option v-for="(item, index) in chooseResourceStoreInfo4.resourceStoreTypes" :key="index" :label="item.name"
                :value="item.rstId" />
            </el-select>
          </el-col>
  
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
22
          <el-col :span="4">
1cad66ad   wuxw   完成采购申请
23
24
25
26
27
28
            <el-select v-model="chooseResourceStoreInfo4.rstId" style="width:100%;margin-right:10px">
              <el-option value="" :label="$t('chooseResourceStore4.selectSubType')" />
              <el-option v-for="(item, index) in chooseResourceStoreInfo4.resourceStoreSonTypes" :key="index"
                :label="item.name" :value="item.rstId" />
            </el-select>
          </el-col>
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
29
30
  4
          <el-col :span="4">
1cad66ad   wuxw   完成采购申请
31
32
33
            <el-input v-model.trim="chooseResourceStoreInfo4._currentResourceStoreName"
              :placeholder="$t('chooseResourceStore4.inputItemName')" />
          </el-col>
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
34
          <el-col :span="4" style="text-align:right">
1cad66ad   wuxw   完成采购申请
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
191
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
            <el-button type="primary" @click="queryResourceStores">
              <i class="el-icon-search"></i>
              {{ $t('common.search') }}
            </el-button>
            <el-button @click="resetResourceStores">
              <i class="el-icon-refresh"></i>
              {{ $t('common.reset') }}
            </el-button>
          </el-col>
        </el-row>
      </div>
  
      <el-table :data="chooseResourceStoreInfo4.resourceStores" border style="width:100%;margin-top:15px">
        <el-table-column width="50">
          <template slot-scope="scope">
            <el-checkbox v-model="chooseResourceStoreInfo4.selectResourceStores" :label="scope.row.resId" />
          </template>
        </el-table-column>
  
        <el-table-column prop="shName" :label="$t('chooseResourceStore4.warehouse')" align="center" />
  
        <el-table-column :label="$t('chooseResourceStore4.itemType')" align="center">
          <template slot-scope="scope">
            {{ scope.row.parentRstName || '-' }} > {{ scope.row.rstName || '-' }}
          </template>
        </el-table-column>
  
        <el-table-column prop="resName" :label="$t('chooseResourceStore4.itemName')" align="center" />
  
        <el-table-column prop="rssName" :label="$t('chooseResourceStore4.spec')" align="center">
          <template slot-scope="scope">
            {{ scope.row.rssName || '-' }}
          </template>
        </el-table-column>
  
        <el-table-column prop="resCode" :label="$t('chooseResourceStore4.code')" align="center" />
  
        <el-table-column prop="isFixedName" :label="$t('chooseResourceStore4.fixedItem')" align="center" />
  
        <el-table-column prop="price" :label="$t('chooseResourceStore4.price')" align="center" />
  
        <el-table-column :label="$t('chooseResourceStore4.stock')" align="center">
          <template slot-scope="scope">
            {{ scope.row.stock }}{{ scope.row.unitCodeName }}
          </template>
        </el-table-column>
      </el-table>
  
      <el-pagination :current-page.sync="page.current" :page-sizes="[10, 20, 30, 50]" :page-size="page.size"
        :total="page.total" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" style="margin-top:20px" />
  
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="getSelectResourceStores">
          {{ $t('common.submit') }}
        </el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import * as api from '@/api/resource/urgentPurchaseApplyStepApi'
  
  export default {
    name: 'ChooseResourceStore4',
    props: {
      resOrderType: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        visible: false,
        chooseResourceStoreInfo4: {
          resourceStores: [],
          selectResourceStores: [],
          _currentResourceStoreName: '',
          parentRstId: '',
          rstId: '',
          shId: '',
          storehouses: [],
          resourceStoreTypes: [],
          resourceStoreSonTypes: [],
          resOrderType: ''
        },
        page: {
          current: 1,
          size: 10,
          total: 0
        }
      }
    },
    methods: {
      open(params) {
        this.visible = true
        this.chooseResourceStoreInfo4.shId = params.shId
        this.chooseResourceStoreInfo4.resOrderType = this.resOrderType
        this._initData()
      },
      async _initData() {
        this.chooseResourceStoreInfo4._currentResourceStoreName = ''
        await this._listStorehouses()
        await this._listResourceStoreTypes()
        this._loadAllResourceStoreInfo(this.page.current, this.page.size)
      },
      handleClose() {
        this.chooseResourceStoreInfo4.selectResourceStores = []
      },
      async _loadAllResourceStoreInfo(page, size) {
        try {
          let shType = ''
          if (this.chooseResourceStoreInfo4.resOrderType === '20000') {
            shType = '2807'
          }
  
          const params = {
            page,
            row: size,
            resOrderType: this.chooseResourceStoreInfo4.resOrderType,
            shType,
            resName: this.chooseResourceStoreInfo4._currentResourceStoreName,
            parentRstId: this.chooseResourceStoreInfo4.parentRstId,
            rstId: this.chooseResourceStoreInfo4.rstId,
            shId: this.chooseResourceStoreInfo4.shId
          }
  
          const { resourceStores, total } = await api.listResourceStores(params)
          this.chooseResourceStoreInfo4.resourceStores = resourceStores
          this.page.total = total
        } catch (error) {
          console.error('获取物品列表失败:', error)
        }
      },
      async _listStorehouses() {
        try {
          const params = {
            page: 1,
            row: 100,
            allowPurchase: 'ON'
          }
          const { data } = await api.listStorehouses(params)
          this.chooseResourceStoreInfo4.storehouses = data
        } catch (error) {
          console.error('获取仓库列表失败:', error)
        }
      },
      async _listResourceStoreTypes() {
        try {
          const communityId = await getCommunityId()
          const params = {
            page: 1,
            row: 100,
            communityId,
            parentId: '0'
          }
          const { data } = await api.listResourceStoreTypes(params)
          this.chooseResourceStoreInfo4.resourceStoreTypes = data
        } catch (error) {
          console.error('获取物品类型列表失败:', error)
        }
      },
      async _listResourceStoreSonTypes() {
        this.chooseResourceStoreInfo4.rstId = ''
        if (!this.chooseResourceStoreInfo4.parentRstId) {
          this.chooseResourceStoreInfo4.resourceStoreSonTypes = []
          return
        }
  
        try {
          const communityId = await getCommunityId()
          const params = {
            page: 1,
            row: 100,
            communityId,
            parentId: this.chooseResourceStoreInfo4.parentRstId
          }
          const { data } = await api.listResourceStoreTypes(params)
          this.chooseResourceStoreInfo4.resourceStoreSonTypes = data
        } catch (error) {
          console.error('获取物品子类型列表失败:', error)
        }
      },
      queryResourceStores() {
        this.page.current = 1
        this._loadAllResourceStoreInfo(this.page.current, this.page.size)
      },
      resetResourceStores() {
        this.chooseResourceStoreInfo4._currentResourceStoreName = ''
        this.chooseResourceStoreInfo4.parentRstId = ''
        this.chooseResourceStoreInfo4.rstId = ''
        this.queryResourceStores()
      },
      getSelectResourceStores() {
        const selectResourceStores = this.chooseResourceStoreInfo4.selectResourceStores
        const resourceStores = this.chooseResourceStoreInfo4.resourceStores
  
        if (selectResourceStores.length < 1) {
          this.$message.warning(this.$t('chooseResourceStore4.selectItemsRequired'))
          return
        }
  
        const _resourceStores = []
        selectResourceStores.forEach(resId => {
          const item = resourceStores.find(r => r.resId === resId)
          if (item) {
            item.remark = ''
            _resourceStores.push(item)
          }
        })
  
        this.$emit('setSelectResourceStores', _resourceStores)
        this.visible = false
      },
      handleSizeChange(val) {
        this.page.size = val
        this._loadAllResourceStoreInfo(this.page.current, val)
      },
      handleCurrentChange(val) {
        this.page.current = val
        this._loadAllResourceStoreInfo(val, this.page.size)
      }
    }
  }
  </script>
  
  <style scoped>
  .filter-container {
    margin-bottom: 20px;
  }
  </style>