|
@@ -0,0 +1,187 @@
|
|
|
+<template>
|
|
|
+ <div v-loading="loading">
|
|
|
+ <el-form ref="form" :model="form" style="width: 100%;padding: 5px" :rules="rules">
|
|
|
+ <el-row>
|
|
|
+ <el-col style="padding-bottom: 10px">
|
|
|
+ <span class="card_title">基本信息</span>
|
|
|
+ <el-card shadow="always" style="padding: 15px 5px 5px 15px">
|
|
|
+ <el-row>
|
|
|
+ <div v-for="(item, index) in form.dynamicItem" :key="index">
|
|
|
+ <el-row style="margin-top: 10px">
|
|
|
+ <el-col :span="2" class="col-txt"><span><span class="red-asterisk">*</span>物料{{ index + 1 }}</span></el-col>
|
|
|
+ <el-col :span="4" class="col-input">
|
|
|
+ <el-form-item :prop="'dynamicItem.' + index + '.material'">
|
|
|
+ <el-input
|
|
|
+ v-model="item.material"
|
|
|
+ placeholder="请填写物料"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6" class="col-input">
|
|
|
+ <el-form-item :prop="'dynamicItem.' + index + '.relationship'">
|
|
|
+ <el-select
|
|
|
+ v-model="item.tax"
|
|
|
+ placeholder="请选择税率"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="itemTax in dc_data.invoice_tax"
|
|
|
+ :key="itemTax.value"
|
|
|
+ :label="itemTax.label"
|
|
|
+ :value="itemTax.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="2" class="col-input">
|
|
|
+ <el-button v-if="index !== 0" type="danger" size="mini" @click="deleteItem(item, index)">-</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="2" class="col-txt">
|
|
|
+ <el-button size="small" type="text" @click="addItem">+继续添加</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" style="text-align: right">
|
|
|
+ <el-button @click="handleClose">关 闭</el-button>
|
|
|
+ <el-button :loading="loading" type="primary" @click="confirmSubmit()">保 存</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import Base from '@/views/base/base.vue'
|
|
|
+import BaseData from '@/views/base/baseData.vue'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'MaterialManageEdit',
|
|
|
+ mixins: [Base, BaseData],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ dc_key: ['invoice_tax'],
|
|
|
+ loading: false,
|
|
|
+ groupId: '',
|
|
|
+ rules: {
|
|
|
+ material: [{ required: true, message: '请输入物料', trigger: 'blur' }]
|
|
|
+
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ dynamicItem: [
|
|
|
+ {
|
|
|
+ material: '',
|
|
|
+ tax: ''
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ initData(data) {
|
|
|
+ this.groupId = data
|
|
|
+ this.initDict(this.dc_key)
|
|
|
+ this.getData()
|
|
|
+ },
|
|
|
+ handleClose() {
|
|
|
+ this.$emit('editClose')
|
|
|
+ },
|
|
|
+ getData() {
|
|
|
+ this.baseRequest('getByGroupId', { groupId: this.groupId }).then(res => {
|
|
|
+ this.form = res.data
|
|
|
+ this.$set(this.form, 'dynamicItem', [])
|
|
|
+ if (res.data) {
|
|
|
+ res.data.forEach(item => {
|
|
|
+ const data = {
|
|
|
+ material: item.material,
|
|
|
+ tax: item.tax + ''
|
|
|
+ }
|
|
|
+ this.form.dynamicItem.push(data)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.addItem()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ confirmSubmit() {
|
|
|
+ const _this = this
|
|
|
+ this.$refs.form.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ const extraData = {
|
|
|
+ groupId: this.groupId,
|
|
|
+ materialJson: JSON.stringify(_this.form.dynamicItem)
|
|
|
+ }
|
|
|
+ const postData = Object.assign({}, _this.form, extraData)
|
|
|
+ this.loading = true
|
|
|
+ this.baseRequest('bind', postData).then(res => {
|
|
|
+ this.loading = false
|
|
|
+ if (res.data.key === 200) {
|
|
|
+ this.$message.success('提交成功')
|
|
|
+ this.$emit('editClose', true)
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addItem(length) {
|
|
|
+ this.form.dynamicItem.push({
|
|
|
+ id: '',
|
|
|
+ customerManagementId: '',
|
|
|
+ name: '',
|
|
|
+ identityCard: '',
|
|
|
+ phone: '',
|
|
|
+ relationship: ''
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 删除方法
|
|
|
+ deleteItem(item, index) {
|
|
|
+ this.form.dynamicItem.splice(index, 1)
|
|
|
+ },
|
|
|
+ baseRequest(opUrl, postData) {
|
|
|
+ return this.$channel.globeRequest('MaterialManageController', opUrl, postData, 'project')
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+ .ch-input .el-input__inner {
|
|
|
+ border-color: #32323A;
|
|
|
+ }
|
|
|
+ .ch-input-size {
|
|
|
+ width: 150px;
|
|
|
+ }
|
|
|
+ .ch-button {
|
|
|
+ border-color: #32323A;
|
|
|
+ background-color: #32323A;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+ .ch-button-warning {
|
|
|
+ margin-left: 10px;
|
|
|
+ border-color: #E6A23C;
|
|
|
+ background-color: #E6A23C;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+ .ch-button-export {
|
|
|
+ margin-left: 10px;
|
|
|
+ border-color: #98CC1F;
|
|
|
+ background-color: #98CC1F;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+ /deep/.el-dialog__header {
|
|
|
+ padding: 10px 20px;
|
|
|
+ }
|
|
|
+ /deep/.el-dialog__body {
|
|
|
+ padding: 10px 20px;
|
|
|
+ }
|
|
|
+</style>
|