123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <template>
- <a-card :bordered="false">
- <a-steps class="steps" :current="currentTab">
- <a-step title="填写基本信息" />
- <a-step title="填写样品信息" />
- <a-step title="填写试验信息" />
- </a-steps>
- <div class="content">
- <step1 v-if="currentTab === 0" ref="data001" @nextStep="nextStep" :disabled="disabled"/>
- <step2 v-if="currentTab === 1" @prevStep="prevStep" ref="ypxx" @nextStep="nextStep" :disabled="disabled" />
- <step3 v-if="currentTab === 2" @submitForm="submitForm" ref="syxx" @prevStep="prevStep" :disabled="disabled" />
- </div>
- </a-card>
- </template>
- <script>
- import { httpAction, getAction, postAction } from '@api/manage'
- import { validateDuplicateValue } from '@/utils/util'
- import Step1 from './step/Step1'
- import Step2 from './step/Step2'
- import Step3 from './step/Step3'
- export default {
- name: 'ItdmWeituoInfoForm',
- components: {
- Step1,
- Step2,
- Step3
- },
- props: {
- //表单禁用
- disabled: {
- type: Boolean,
- default: false,
- required: false
- }
- },
- data() {
- return {
- currentTab: 0,
- weituomodel: {},
- model: {},
- labelCol: {
- xs: { span: 24 },
- sm: { span: 5 }
- },
- wrapperCol: {
- xs: { span: 24 },
- sm: { span: 16 }
- },
- confirmLoading: false,
- validatorRules: {},
- url: {
- add: '/weituo/itdmWeituoInfo/add',
- edit: '/weituo/itdmWeituoInfo/edit',
- queryById: '/weituo/itdmWeituoInfo/queryById'
- }
- }
- },
- computed: {
- formDisabled() {
- return this.disabled
- },
- baseInfos() {
- return this.$store.getters.baseInfos
- },
- yangpinInfos() {
- return this.$store.getters.yangpinInfos
- },
- shiyanInfos() {
- return this.$store.getters.shiyanInfos
- },
- },
- created() {
- //备份model原始值
- this.modelDefault = JSON.parse(JSON.stringify(this.model))
- },
- methods: {
- nextStep() {
- if (this.currentTab < 3) {
- this.currentTab += 1
- }
- },
- prevStep() {
- if (this.currentTab > 0) {
- this.currentTab -= 1
- }
- },
- add() {
- this.model = Object.assign({}, this.modelDefault)
- this.visible = true
- },
- edit(record) {
- const that = this
- const select = { id: record.id }
- getAction(this.url.queryById, select).then((res) => {
- if (res.success) {
- this.model.id = res.result.id
- // sessionStorage.setItem('data', JSON.stringify(res.result.data))
- // sessionStorage.setItem('yangpin', JSON.stringify(res.result.yangpins))
- // sessionStorage.setItem('yangpinkz', JSON.stringify(res.result.pinShiYans))
- this.$store.commit('SET_BASEINFO', res.result.data);
- this.$store.commit('SET_YANGPININFO', res.result.yangpins);
- this.$store.commit('SET_SHIYANINFO', res.result.pinShiYans);
- this.$store.commit('SET_COUNTYP', res.result.yangpins.length>0?res.result.yangpins.length>0:1);
- this.$store.commit('SET_COUNTSY', res.result.pinShiYans.length>0?res.result.pinShiYans.length>0:1);
- this.$refs.data001.init()
- } else {
- that.$message.warning(res.message)
- }
- })
- this.visible = true
- },
- submitForm() {
- const that = this
- // 触发表单验证
- // this.weituomodel = JSON.parse(sessionStorage.getItem('data'))
- // this.weituomodel.yangpins = JSON.parse(sessionStorage.getItem('yangpin'))
- // this.weituomodel.pinShiYans = JSON.parse(sessionStorage.getItem('yangpinkz'))
- // console.log(JSON.parse(sessionStorage.getItem('yangpinkz')))
- // var pinShiYans = JSON.parse(sessionStorage.getItem('yangpinkz'))
- this.weituomodel = this.baseInfos
- this.weituomodel.yangpins = this.yangpinInfos
- this.weituomodel.shiyanInfos = this.shiyanInfos.map(item => {
- item.standardRequirement = item.standardRequirementQ.join(',')
- return item
- })
-
- that.confirmLoading = true
- let httpurl = ''
- let method = ''
- if (!this.model.id) {
- httpurl += this.url.add
- method = 'post'
- } else {
- httpurl += this.url.edit
- method = 'put'
- this.weituomodel.id = this.model.id
- }
- console.log(this.weituomodel)
- httpAction(httpurl, this.weituomodel, method).then((res) => {
- if (res.success) {
- that.$message.success(res.message)
- that.$emit('ok')
- } else {
- that.$message.warning(res.message)
- }
- }).finally(() => {
- that.confirmLoading = false
- })
- },
- handleCategoryChange(value, backObj) {
- this.model = Object.assign(this.model, backObj)
- }
- }
- }
- </script>
|