<template>
  <div class="print-count">
    <!-- <el-divider></el-divider> -->
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item>
        <span>仓位找货优先级 （生成新的仓位后务必重新设定一下优先级）</span>
        <el-input
          class="textarea"
          type="textarea"
          v-model="form.content"
          placeholder="请输入内容"
          maxlength="300"
          show-word-limit
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="saveLog()">保存日志</el-button>
        <el-button @click="lookeLog()">操作日志</el-button>
      </el-form-item>
    </el-form>
    <!-- 操作日志 -->
    <openLogModal ref="openLogModal" :data="data" />
  </div>
</template>
  
  <script lang="ts">
import openLogModal from "./components/openLogModal.vue"; //拆分
import { Component, Prop, Vue, Watch } from "vue-property-decorator";

@Component({ components: { openLogModal } })
export default class packing extends Vue {
  form = {
    userName: (this as any).$store.getters.userInfo.userName,
    content: '',
    createTime: '',
  };
  index = 0;
  data: Array<any> = [];
  data1: Array<any> = [];
  saveLog() {
    const now = new Date();
    this.form.createTime = now.toLocaleString();

    if (this.form.content) {
      this.$message({
        message: "保存日志成功！",
        type: "success",
      });
      // const aa=this.form
      this.index++;

      const datas: string | null = localStorage.getItem("logLsit");
      console.log("datas========", datas);
      let data1:any=[]
      if (datas) {
        let from = JSON.stringify(this.form);
        // this.data1.push(JSON.parse(from));
        // let from = JSON.stringify(this.form);
        data1.push(JSON.parse(from));
        let datacun = JSON.parse(datas);
        this.data = data1.concat(datacun);
        localStorage.setItem("logLsit", JSON.stringify(this.data));
        console.log("提交的数据1========", this.data);
      } else {
        let from = JSON.stringify(this.form);
        this.data.push(JSON.parse(from));
        localStorage.setItem("logLsit", JSON.stringify(this.data));
        console.log("提交的数据2========", this.data);
      }
    } else {
      this.$message({
        message: "输入内容不能为空！",
        type: "warning",
      });
    }
  }
  lookeLog() {
    (this.$refs.openLogModal as any).setShow(true);
    (this.$refs.openLogModal as any).setValue(this.data);
  }
}
</script>
  
  <style lang="scss" >
.print-count {
  padding: 16px;
  width: 100%;
  height: 100%;
  overflow-y: hidden;
}
.textarea textarea {
  height: 400px !important;
}
.el-textarea__inner {
  height: 400px !important;
}
</style>