zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
1
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
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<template>
  <div>
    <div class="left">
      <LeftMenus :menuItems="menuItems"
                 @jump="jump"
                 @backList="backList" />
    </div>
    <div class="right"
         @scroll="onScroll"
         ref="proFreePayment">
      <div class="scroll_item"
           v-for="(item, index) in menuItems"
           :key="index">
        <ModuleTitle :title="item.label" />
        <div v-if="!!item.children && item.children.length > 0"
             style="background: #fff;">
          <div class="item_set_class"
               v-for="(child, index) in item.children"
               :key="index">
            <MenusTitle :title="child.label" />
            <CreateForms :edit="type === 'edit'"
                         v-if="child.type === 'FORMS'"
                         :screenWidth="screenWidth"
                         :ref="child.name"
                         :formItems="child.formItems"
                         :defValues="child.defValues"
                         :formRules="child.formRules"
                         @handleSelOnChange="handleSelOnChange"
                         @handleElmentChange="handleElmentChange" />
          </div>
        </div>
        <NperConfigList v-if="item.name === 'NPERCONFIGLIST'"
                        ref="nperRef"
                        :edit="type === 'edit'" />
      </div>
      <el-row class="right_opreat">
        <el-button class="back-button"
                   @click="handleBtnBack"
                   :disabled="subLoading">返回</el-button>
        <el-button class="save_button"
                   @click="handleSave"
                   :disabled="subLoading">保存</el-button>
        <el-button type="primary"
                   class="submit_button"
                   @click="submitForm"
                   :loading="subLoading">提交</el-button>
      </el-row>
      <el-dialog custom-class="product_submit_dialog"
                 :visible.sync="commitDialogVisible"
                 width="400px"
                 center>
        <div class="messageCheck">
          <i class="el-icon-success checkSuccess"></i>
          <div class="tip">提交成功</div>
        </div>
        <span slot="footer"
              class="dialog-footer">
          <el-button @click="enterMessages">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import { PRODUCTFREEMENUS } from '../utils/menusConfig.js'
import LeftMenus from '../components/LeftMenus.vue'
import ModuleTitle from '../components/ModuleTitle.vue'
import MenusTitle from '../components/MenusTitle.vue'
import CreateForms from '../components/CreateForms.vue'
import NperConfigList from './components/NperConfigList'
import { qryCurrentInputUserInfo, addOrUpdateCusPaymentType, qryCondition, qryCusPaymentTypeInfo } from '../api/productManage.api.js'
export default {
  data () {
    return {
      screenWidth: document.documentElement.clientWidth || 1660, // 屏幕宽度
      menuItems: [...PRODUCTFREEMENUS(true)],
      subLoading: false,
      rowSerialno: this.$route.query.serialno || '',
      serialno: this.$route.query.type === 'edit' ? this.$route.query.serialno : '', // 保存基本信息返回的流水号
      type: this.$route.query.type || '',
      commitDialogVisible: false
    }
  },
  components: {
    LeftMenus,
    ModuleTitle,
    MenusTitle,
    CreateForms,
    NperConfigList
  },
  computed: {},
  async mounted () {
    window.addEventListener('scroll', this.onScroll)
    window.addEventListener('resize', this.getScreenWidth)
    this.$router.afterEach((to, from, next) => {
      window.scrollTo(0, 0)
    })
    await this.getCurrentInputUserInfo()
    await this.getCondition('IsInUse', 'status')
    this.type === 'edit' && this.qryCusPaymentTypeInfo()
  },
  destroyed () {
    window.removeEventListener('scroll', this.onScroll)
    window.removeEventListener('resize', this.getScreenWidth)
  },
  deactivated () { },
  methods: {
    // 返回列表
    backList (type) {
      this.$router.go(-1)
    },
    handleSelOnChange () { },
    handleElmentChange () { },
    handleBtnBack () { },
    async saveBase () {
      const baseForm = this.$refs.BASEINFO[0]
      const {
        componenremark,
        effectdate,
        failuredate,
        paymentname,
        paymentno,
        status
      } = baseForm.formValues
      const params = {
        componenremark,
        effectdate,
        failuredate,
        paymentname,
        paymentno,
        serialno: this.serialno || '',
        status
      }
      const baseRes = await addOrUpdateCusPaymentType(params)
      if (!baseRes || baseRes.code !== '00') {
        return false
      }
      this.serialno = baseRes.result.serialNo
      const nperRef = this.$refs.nperRef[0]
      nperRef.handleSave()
    },
    handleSave () {
      const baseForm = this.$refs.BASEINFO[0]
      baseForm.$refs['createForm'].validate(async valid => {
        if (valid) {
          this.saveBase()
        } else {
          this.$message.warning('请完基本信息必填项!')
          return false
        }
      })
    },
    submitForm () { },
    enterMessages () { },
    // 获取信息
    async qryCusPaymentTypeInfo () {
      const { rowSerialno } = this
      if (!rowSerialno) {
        return false
      }
      const params = { serialno: rowSerialno }
      const detailRes = await qryCusPaymentTypeInfo(params)
      if (!detailRes || detailRes.code !== '00') {
        return false
      }
      const result = detailRes.result
      const itemMenus = [...this.menuItems].map(item => {
        const newItem = { ...item }
        if (newItem.name === 'BASEINFO') {
          const newChildren = newItem.children.map(child => {
            const newChild = { ...child }
            newChild.defValues = { ...newChild.defValues, ...result }
            return newChild
          })
          newItem.children = newChildren
        }
        return newItem
      })
      this.$set(this, 'menuItems', itemMenus)
    },
    getScreenWidth () {
      this.$set(this, 'screenWidth', document.body.offsetWidth)
    },
    async getCurrentInputUserInfo () {
      const infoRes = await qryCurrentInputUserInfo()
      if (!infoRes || infoRes.code !== '00') {
        return
      }
      this.infoData = infoRes.result
    },
    /**
     * 获取下拉选择项
     */
    async getCondition (conditionName, name) {
      const params = { conditionName }
      const res = await qryCondition(params)
      if (res.code !== '00') {
        return false
      }
      const itemMenus = [...this.menuItems].map(item => {
        const newItem = { ...item }
        if (newItem.name === 'BASEINFO') {
          const newChildren = newItem.children.map(child => {
            const newChild = { ...child }
            const newFormItems = newChild.formItems.map(forms => {
              const newForms = { ...forms }
              if (newForms.name === name) {
                newForms.options = res.result
              }
              return newForms
            })
            newChild.formItems = newFormItems
            newChild.defValues = { ...newChild.defValues, ...this.infoData, inputdata: this.infoData.inputtime, updatedate: this.infoData.updatetime }
            return newChild
          })
          newItem.children = newChildren
        }
        return newItem
      })
      this.$set(this, 'menuItems', itemMenus)
    },
    jump (index) {
      const { menuItems } = this
      const items = document.querySelectorAll('.scroll_item')
      items.forEach((item, i) => {
        this.$set(this.menuItems, i, {
          ...menuItems[i],
          isActive: index === i
        })
        if (index === i) {
          items[i].scrollIntoView({
            block: 'start', // 默认跳转到顶部
            behavior: 'smooth' // 滚动的速度
          })
        }
      })
    },
    onScroll (e) {
      const scrollItems = document.querySelectorAll('.scroll_item')
      const { menuItems } = this
      for (let i = scrollItems.length - 1; i >= 0; i--) {
        // 判断滚动条滚动距离是否大于当前滚动项可滚动距离
        const judge =
          e.target.scrollingElement.scrollTop + 50 >=
          scrollItems[i].offsetTop - scrollItems[0].offsetTop
        if (judge) {
          scrollItems.forEach((item, index) => {
            this.$set(this.menuItems, index, {
              ...menuItems[index],
              isActive: index === i
            })
          })
          break
        }
      }
      const scrollTop =
        document.documentElement.scrollTop || document.body.scrollTop
      // 变量windowHeight是可视区的高度
      const windowHeight =
        document.documentElement.clientHeight || document.body.clientHeight
      // 变量scrollHeight是滚动条的总高度
      const scrollHeight =
        document.documentElement.scrollHeight || document.body.scrollHeight
      // 滚动条到底部的条件
      if (scrollTop + windowHeight === scrollHeight) {
        const newMenuItems = [...this.menuItems].map((item, i) => {
          const newItem = { ...item }
          newItem.isActive = i === this.menuItems.length - 1
          return newItem
        })
        this.menuItems = newMenuItems
      }
    }
  }
}
</script>
<style lang="postcss" scoped>
.left {
  width: 160px;
  height: 100%;
  position: fixed;
  outline: 1px solid #eeeeee;
  background: #fff;
  z-index: 999;
}
.right {
  position: absolute;
  width: calc(100% - 220px);
  padding: 20px 30px;
  background: rgba(249, 249, 249, 1);
  right: 0;
  & >>> .el-dialog__wrapper {
    z-index: 2006;
    & .product_submit_dialog {
      & .el-dialog__footer {
        & .dialog-footer {
          & .el-button--default {
            width: 120px;
            height: 30px;
            border-radius: 4px;
            line-height: 2px;
            border: 1px solid rgba(204, 204, 204, 1);
          }
        }
      }
    }
  }
  & >>> .pricing_dialog {
    width: 1000px;
    & .el-dialog__footer {
      & .dialog-footer {
        & .el-button--default {
          width: 120px;
          height: 30px;
          line-height: 7px;
          border-radius: 4px;
          border: 1px solid rgba(204, 204, 204, 1);
          & span {
            margin-left: -9px;
          }
        }
        & .el-button--primary {
          width: 120px;
          height: 30px;
          line-height: 7px;
          background: #0081f0;
          border-color: #0081f0;
          border-radius: 4px;
          margin-left: 40px;
        }
      }
    }
  }
  & >>> .back_dialog {
    width: 450px;
    & .el-dialog__body {
      text-align: center;
    }
  }
}
.scroll_item {
  min-height: 200px;
  background: rgba(249, 249, 249, 1);
  padding-bottom: 30px;
}
.item_set_class {
  padding-left: 14px;
}
.right_opreat {
  position: fixed;
  width: 100%;
  text-align: center;
  line-height: 80px;
  background: #fff;
  z-index: 6;
  bottom: 0;
  & .el-button--default {
    width: 120px;
    height: 30px;
    margin-left: -80px;
    line-height: 7px;
    border-radius: 4px;
    border: 1px solid rgba(204, 204, 204, 1);
  }
  & .el-button--primary {
    width: 120px;
    height: 30px;
    line-height: 7px;
    background: #0081f0;
    border-color: #0081f0;
    border-radius: 4px;
    margin-left: 40px;
  }
  & .back-button {
    margin-right: 120px;
  }
}
.messageCheck {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.checkSuccess {
  font-size: 80px;
  color: rgb(82, 196, 26);
}
.tip {
  margin-top: 10px;
  font-size: 20px;
}
</style>