LAPTOP-FO2T5SIU\35838 5 ヶ月 前
コミット
2813cfe1ae
共有2 個のファイルを変更した340 個の追加0 個の削除を含む
  1. 187 0
      src/views/invoice/components/materialManageEdit.vue
  2. 153 0
      src/views/invoice/materialManage.vue

+ 187 - 0
src/views/invoice/components/materialManageEdit.vue

@@ -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>

+ 153 - 0
src/views/invoice/materialManage.vue

@@ -0,0 +1,153 @@
+<template>
+  <div>
+    <el-row class="handle-box" style="margin-bottom: 10px">
+      <el-col :span="24">
+        <!--        <el-button size="small" class="ch-button-add" @click="handleAdd()"><i class="el-icon-plus" />&nbsp;新增</el-button>-->
+      </el-col>
+    </el-row>
+    <el-row class="handle-box">
+      <el-col :span="24">
+        <el-table v-loading="loading" :data="AllData" stripe row-class-name="g_table_row">
+          <el-table-column align="center" type="index" width="60" label="序号" />
+          <el-table-column align="center" label="适用小区" prop="groupName" />
+          <el-table-column align="center" label="适用物料类型" prop="suitMaterialStr" />
+          <el-table-column align="center" label="操作" width="180">
+            <template v-slot="scope">
+              <el-button size="mini" type="primary" class="editButton" @click="handleEdit(scope.row)">编辑</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        <div class="table-page">
+          <el-pagination
+            :current-page.sync="search.pageNum"
+            :page-size="search.pageSize"
+            background
+            layout="total, prev, pager, next"
+            :total="total"
+            @current-change="handleCurrentChange"
+          />
+        </div>
+      </el-col>
+    </el-row>
+    <el-dialog
+      :title="dialogTitle"
+      :visible.sync="dialogVisible"
+      width="75%"
+      top="50px"
+      :close-on-press-escape="false"
+      :close-on-click-modal="false"
+      class="statistic_base"
+      :append-to-body="true"
+      :modal-append-to-body="true"
+      custom-class="tagdialog"
+      @close="handleClose"
+    >
+      <material-manage-edit v-if="dialogVisible" ref="edit" @editClose="handleClose" />
+    </el-dialog>
+  </div>
+</template>
+<script>
+
+import MaterialManageEdit from '@/views/invoice/components/materialManageEdit.vue'
+
+export default {
+    name: 'MaterialManage',
+    components: { MaterialManageEdit },
+    data() {
+        return {
+            // 列表相关
+            search: {
+                pageNum: 1,
+                pageSize: 10
+            },
+            total: 0,
+            AllData: [],
+            loading: false,
+            // 弹框相关
+            dialogVisible: false,
+            dialogTitle: ''
+        }
+    },
+    mounted() {
+        this.getData()
+    },
+    methods: {
+        getData() {
+            const _this = this
+            _this.loading = true
+            _this.AllData = []
+            this.baseRequest('listByModel', this.search).then((res) => {
+                if (res.data.rows) {
+                    _this.AllData = res.data.rows
+                    _this.total = res.data.total
+                }
+                _this.loading = false
+            })
+        },
+        handleSearch() {
+            this.search.pageNum = 1
+            this.getData()
+        },
+        handleCurrentChange(val) {
+            this.search.pageNum = val
+            this.getData()
+        },
+        handleReset() {
+            for (const i in this.search) {
+                if (i !== 'pageNum' && i !== 'pageSize') {
+                    this.search[i] = ''
+                }
+            }
+            this.handleSearch()
+        },
+        handleEdit(row) {
+            this.dialogVisible = true
+            this.dialogTitle = '编辑'
+            this.$nextTick(() => {
+                this.$refs.edit.initData(row.groupId)
+            })
+        },
+        handleClose(refresh) {
+            this.dialogVisible = false
+            if (refresh) {
+                this.getData()
+            }
+        },
+        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>