<template>
  <div>
    <div>
      <el-row style="margin:20px 0px">
        <el-col :xl="12" :lg="12" :md="12" :sm="12" :xs="24">
          <el-form
            :model="FixedAssetsAddDTO"
            :rules="rules"
            ref="ruleForm"
            label-width="100px"
            class="demo-ruleForm"
          >
            <el-form-item label="资产编号" prop="fixedCode">
              <el-input v-model="FixedAssetsAddDTO.fixedCode" laceholder="请输入资产编号"></el-input>
            </el-form-item>
            <el-form-item label="资产名称" prop="fixedName">
              <el-input v-model="FixedAssetsAddDTO.fixedName" laceholder="请输入资产名称"></el-input>
            </el-form-item>
            <el-form-item label="资产金额" prop="fixedMoney">
              <el-input v-model="FixedAssetsAddDTO.fixedMoney" laceholder="请输入资产金额"></el-input>
            </el-form-item>
            <el-form-item label="资产地址" prop="fixedAddress">
              <el-input v-model="FixedAssetsAddDTO.fixedAddress" laceholder="请输入资产地址"></el-input>
            </el-form-item>
            <el-form-item label="提交时间">
              <el-input v-model="FixedAssetsAddDTO.registerTime" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="登记详情">
              <el-input
                type="textarea"
                :rows="2"
                placeholder="请输入登记信息"
                v-model="FixedAssetsAddDTO.fixedDetails"
              ></el-input>
            </el-form-item>
            <el-form-item label="登记备注">
              <el-input v-model="FixedAssetsAddDTO.registerRemarks" laceholder="请输入登记备注"></el-input>
            </el-form-item>
            <el-form-item label="资产负责人">
              <el-input v-model="FixedAssetsAddDTO.fixedControllerName" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item style="margin-top:60px">
              <el-button type="success" @click="submitForm()">提交</el-button>
              <el-button @click="back()">返回</el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import { selectByFixedId, updates } from "@/api/assets";
export default {
  data() {
    return {
      FixedAssetsAddDTO: {
        companyId: null,
        fixedAddress: null, //资产地址
        fixedCode: null, //资产编号（不重复）
        fixedController: null, //选择资产负责人
        fixedDetails: null, //登记详情
        fixedMoney: null, //资产金额
        fixedName: null, //资产名称
        fixedState: 0, //默认为0
        registerRemarks: null, //登记备注
        registerTime: null, //登记时间
        userId: null
      }, //添加资产

      rules: {
        fixedName: [
          { required: true, message: "请输入活动名称", trigger: "change" }
        ],
        fixedCode: [
          { required: true, message: "请收入资产编号", trigger: "change" }
        ],
        fixedAddress: [
          {
            required: true,
            message: "请输入资产地址",
            trigger: "change"
          }
        ],
        fixedMoney: [
          { required: true, message: "请输入资产金额", trigger: "change" }
        ]
      }
    };
  },
  computed: {
    fixedId() {
      return this.$route.query.id;
    }
  },
  created() {
    this.selectget();
  },

  methods: {
    //查询要修改的信息
    selectget() {
      selectByFixedId({ fixedId: this.fixedId })
        .then(res => {
          if (res.success) {
            this.FixedAssetsAddDTO = res.data;
          } else {
            this.$message.error(res.msg);
          }
        })
        .catch(e => {
          this.$message.error("查询该条资产失败");
        });
    },
    //提交
    submitForm() {
      updates(this.FixedAssetsAddDTO)
        .then(res => {
          if (res.success) {
            this.$message({
              message: "修改资产信息成功",
              type: "success"
            });
           this.$router.push("/administrationlsit");
          } else {
               this.$message.error(res.msg);
          }
        })
        .catch(e => {
          this.$message.error("错了哦，这是一条错误消息");
        });
    },
    //返回
    back(){
         this.$router.push("/administrationlsit");
    }
  }
};
</script>

<style>
</style>