|
|
@@ -0,0 +1,137 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-dialog
|
|
|
+ v-loading="loading"
|
|
|
+ :show-close="false"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :visible.sync="isShow"
|
|
|
+ :title="this.curObj && this.curObj.id ? `编辑数据${this.curObj.year}-第${this.curObj.week}周` : '添加数据'"
|
|
|
+ :fullscreen="false"
|
|
|
+ width="900px"
|
|
|
+ custom-class="xl-dialog"
|
|
|
+ center
|
|
|
+ >
|
|
|
+ <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="160px">
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
|
|
|
+ <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </base-form>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ components: {},
|
|
|
+ mixins: [...mixins],
|
|
|
+ props: {
|
|
|
+ isShow: Boolean,
|
|
|
+ curObj: Object
|
|
|
+ },
|
|
|
+ inject: ['parentData'],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ formData: [],
|
|
|
+ loading: true,
|
|
|
+ cObj: {},
|
|
|
+ isShowMap: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ isShow: function(val) {
|
|
|
+ if (val) {
|
|
|
+ this.getDef()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getISOWeekNumber(date) {
|
|
|
+ const target = new Date(date.valueOf());
|
|
|
+ const dayNumber = (date.getDay() + 6) % 7;
|
|
|
+ target.setDate(target.getDate() - dayNumber + 3);
|
|
|
+ const firstThursday = target.valueOf();
|
|
|
+ target.setMonth(0, 1);
|
|
|
+ if (target.getDay() !== 4) {
|
|
|
+ target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7);
|
|
|
+ }
|
|
|
+ const weekNumber = 1 + Math.ceil((firstThursday - target) / 604800000);
|
|
|
+ return weekNumber;
|
|
|
+ },
|
|
|
+ getDef() {
|
|
|
+ const params = { ...this.curObj }
|
|
|
+ // params.data_time = params.year+'-W'+params.week
|
|
|
+ // if (params[params.big_data_zone+'_quantity']) {
|
|
|
+ // params.quantity = params[params.big_data_zone+'_quantity']
|
|
|
+ // delete params[params.big_data_zone+'_quantity']
|
|
|
+ // }
|
|
|
+ // if (params[params.big_data_zone+'_area']) {
|
|
|
+ // params.area = params[params.big_data_zone+'_area']
|
|
|
+ // delete params[params.big_data_zone+'_area']
|
|
|
+ // }
|
|
|
+ this.formData = [
|
|
|
+ { label: '类型', key: 'big_data_type', class: 'c-2', rules: 1, type: 'select', options: this.$dictData.big_data_type },
|
|
|
+ ]
|
|
|
+
|
|
|
+ // 只有当不存在curObj.id时才添加成交时间字段
|
|
|
+ if (!this.curObj || !this.curObj.id) {
|
|
|
+ this.formData.unshift({ label: '成交时间', key: 'data_time', class: 'c-2', type: 'datePicker', rules: 1, type2: 'week', format:"yyyy 第 WW 周"})
|
|
|
+ }
|
|
|
+ const zone = this.$dictData.big_data_zone || []
|
|
|
+ console.log(zone)
|
|
|
+ zone.forEach(item => {
|
|
|
+ this.formData.push({ label: item.key+'销售数量', key: item.val+'_quantity', class: 'c-2', rules: 1, type: 'input' })
|
|
|
+ this.formData.push({ label: item.key+'销售面积', key: item.val+'_area', class: 'c-2', rules: 1, type: 'input' })
|
|
|
+ })
|
|
|
+ this.setDefaultValue(params)
|
|
|
+ },
|
|
|
+ close(str) {
|
|
|
+ const that = this
|
|
|
+ if (str === 'confirm') {
|
|
|
+ this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ const oldform = this.$refs.ruleForm.baseForm
|
|
|
+ let newForm = { ...oldform }
|
|
|
+ // if (newForm.quantity) {
|
|
|
+ // newForm[newForm.big_data_zone+'_quantity'] = newForm.quantity
|
|
|
+ // delete newForm.quantity
|
|
|
+ // }
|
|
|
+ if (newForm.data_time) {
|
|
|
+ const date = new Date(newForm.data_time);
|
|
|
+ newForm.year = date.getFullYear();
|
|
|
+ newForm.week = that.getISOWeekNumber(date);
|
|
|
+ delete newForm.data_time
|
|
|
+ }
|
|
|
+ let apiStr = 'admbigdataquantityweekadd'
|
|
|
+ if (this.curObj.id) {
|
|
|
+ apiStr = 'admbigdataquantityweekedit'
|
|
|
+ newForm.id = this.curObj.id
|
|
|
+ newForm.year = this.curObj.year
|
|
|
+ newForm.week = this.curObj.week
|
|
|
+ }
|
|
|
+ this.$api.facility[apiStr](newForm).then(data => {
|
|
|
+ this.$msgs(this.curObj.id ? '编辑成功' : '新增成功')
|
|
|
+ this.$emit('close', newForm)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$emit('close')
|
|
|
+ this.setDefaultValue()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+@import "../../../../styles/libEdit.scss";
|
|
|
+.lib-edit {
|
|
|
+ padding-top: 0;
|
|
|
+ width:100%;
|
|
|
+ ::v-deep .el-form-item {
|
|
|
+ margin-bottom: 10px;
|
|
|
+ }
|
|
|
+ ::v-deep .el-date-editor.el-input {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|