<template>
  <div class="main_box">
    <navbar title="日常任务列表-处理"></navbar>
    <div class="wrapper">
      <van-form ref="form">
        <van-cell title="重点工作类别" :value="searchForm.workType" />
        <van-cell title="清单详情" :value="searchForm.workDetail" />
        <van-cell title="频率" :value="formatFn('frequencyType',searchForm.frequencyType)" />
        <van-cell title="岗位名称" :value="searchForm.postName" />
        <van-cell title="是否逾期" :value="searchForm.isOverdue == '0' ? '是':'否'" />
        <van-cell title="柜员姓名" :value="searchForm.nickName" />
        <van-cell title="开始时间" :value="searchForm.startTime" />
        <van-cell title="结束时间" :value="searchForm.endTime" />
        <van-field
          v-model="status"
          label="状态"
          is-link
          readonly
          placeholder="请选择"
          @click="showStatusPicker = true"
        ></van-field>
        <van-field
          label="备注"
          v-model="searchForm.remark"
          placeholder="请输入"
          type="textarea"
          :row="10"
        ></van-field>
      </van-form>
      <div class="formBtn">
        <van-button plain color="#2372eb" @click="handleCancle" class="qx">取消</van-button>
        <van-button type="primary" @click="handleSave">提交</van-button>
      </div>
    </div>
    <van-popup v-model="showStatusPicker" position="bottom">
      <van-picker
        show-toolbar
        :columns="statusList"
        value-key="label"
        @cancel="showStatusPicker = false"
        @confirm="onConfirmStatus"
      />
    </van-popup>
  </div>
</template>
<script>
import navbar from "../../../components/navbar/navbar.vue";
import {
  workRecordSubmit,
  systemUserOptionselect,
  systemUserType
} from "@/service/api/home";
import {
  Tab,
  Tabs,
  Icon,
  Button,
  Search,
  RadioGroup,
  Radio,
  List,
  PullRefresh,
  Dialog,
  Toast,
  Picker,
  DatetimePicker,
  Form,
  Field
} from "vant";
export default {
  data() {
    return {
      frequencyTypeList: [
        {
          label: "每日",
          value: "0"
        },
        {
          label: "每周",
          value: "1"
        },
        {
          label: "每月",
          value: "2"
        },
        {
          label: "每季",
          value: "3"
        },
        {
          label: "每年",
          value: "4"
        }
      ],
      statusList: [
        {
          label: "未完成",
          value: "0"
        },
        {
          label: "部分完成",
          value: "1"
        },
        {
          label: "已完成",
          value: "2"
        }
      ],
      searchForm: {
        workType: "",
        workDetail: "",
        frequencyType: "",
        postName: "",
        isOverdue: "",
        status: "",
        remark: "",
        nickName: "",
        startTime: "",
        endTime: ""
      },
      status: "",
      showStatusPicker: false
    };
  },
  components: {
    navbar: navbar,
    VanTab: Tab,
    VanTabs: Tabs,
    VanIcon: Icon,
    VanButton: Button,
    VanSearch: Search,
    VanRadioGroup: RadioGroup,
    VanRadio: Radio,
    VanList: List,
    VanPullRefresh: PullRefresh,
    VanToast: Toast,
    [Dialog.Component.name]: Dialog.Component,
    VanPicker: Picker,
    VanDatetimePicker: DatetimePicker,
    VanForm: Form,
    VanField: Field
  },
  created() {
    this.searchForm = JSON.parse(sessionStorage.getItem("workmngdaytaskedit"));
    if (this.searchForm.status == "0") {
      this.status = "未完成";
    } else if (this.searchForm.status == "1") {
      this.status = "部分完成";
    } else if (this.searchForm.status == "2") {
      this.status = "已完成";
    }
  },
  methods: {
    formatFn(t, v) {
      if (t == "frequencyType") {
        let arr = _.filter(this.frequencyTypeList, { value: v });
        return arr[0].label;
      }
    },
    onConfirmStatus(item) {
      this.searchForm.status = item.value;
      this.status = item.label;
      this.showStatusPicker = false;
    },
    handleCancle() {
      this.$router.go(-1);
    },
    handleSave() {
      if (!this.status) {
        this.$toast("请选择状态");
        return;
      }
      let arr = [];
      arr.push({
        id: this.searchForm.id,
        status: this.searchForm.status,
        remark: this.searchForm.remark
      });
      workRecordSubmit(arr).then(res => {
        if (res.code == 200) {
          this.$toast("处理成功！");
          this.$router.go(-1);
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
::v-deep .van-field__label {
  color: #171718 !important;
}
::v-deep .van-field__control:disabled {
  color: #171718 !important;
  text-fill-color: #171718 !important;
  -webkit-text-fill-color: #171718 !important;
}
.formBtn {
  display: flex;
  justify-content: space-between;

  /deep/ .van-button {
    width: 48%;
  }
}
.sphandle {
  position: absolute;
  right: 10px;
  top: 8px;
  background-color: rgba(233, 241, 253);
  color: #2372eb;
  padding: 5px 5px;
  border-radius: 5px;
  width: 44px;
}
.sp {
  display: flex;
  flex-direction: row;
  font-size: 14px;
  color: #595959;
  &_ft {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
  }
  &_lf {
    // width: 100px;
    flex: 0 0 auto;
  }
  &_rg {
    margin-left: 8px;
    flex: 1;
    min-width: 0px;
    line-height: 22px;
  }
}
.main_box {
  position: relative;
  .backTop {
    position: fixed;
    bottom: 150px;
    right: 15px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #4682ff;
    box-shadow: 0px -2px 6px 0px rgba(70, 130, 255, 1);
    color: #fff;
    transform: rotate(180deg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    .heng {
      display: block;
      width: 15px;
      border: 1px solid #fff;
    }
  }
}
.wrapper {
  padding-top: 46px;
  min-height: 100vh;
  font-size: 16px;
  padding-bottom: 60px;
  // position: relative;
  .banner-box {
    // position: fixed;
  }
}
.task-box {
  margin: 12px;
  background: #1990ff;
  border-radius: 4px;
  padding-bottom: 9px;
  .task-title {
    font-size: 16px;
    color: #fff;
    text-align: center;
    line-height: 43px;
    font-weight: 600;
  }
  .grid_item_middle {
    margin: 0 8px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 4px;
  }
}

.wrapper_top {
  background-color: #fff;
  padding: 15px 20px;
}

.search-input {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 15px;
  background: #fff;
  .special-search {
    ::v-deep .van-field__control {
      font-size: 12px;
    }
  }
}

.special-input-box {
  margin-top: 0;
}

.search_btn {
  background-color: rgb(24, 144, 255);
  border-radius: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  color: #fff;
  font-size: 20px;
  .icon {
    display: inline-block;
    width: 40px;
    text-align: center;
  }
}
.reset {
  background: #f7f8fa;
  color: rgba(0, 0, 0, 0.45);
  margin-left: 3px;
  margin-right: 8px;
}

/deep/ .van-search {
  width: 100%;
  padding: 5px 8px;
}

.radio_box {
  display: flex;
  align-items: center;
  margin: 15px 0 15px 15px;
}

.btn_box {
  padding: 8px 16px;
  background-color: #fff;
}

.isChecked {
  background-color: rgb(35, 114, 235);
  color: #fff;
  border-radius: 4px;
}
.grid_item {
  margin-top: 8px;
  padding: 10px 15px;
  background-color: #fff;
  position: relative;
  .item_content_box {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .item_content {
      margin-top: 8px;
      flex: 0 0 50%;
      font-size: 12px;
      .item_left {
        color: #8c8c8c;
      }
      .item_right {
        color: #262626;
        font-weight: 600;
        word-break: break-all;
      }
    }
  }
  .item_footer {
    text-align: right;
    margin-top: 10px;
    .btn {
      height: 30px;
      margin-left: 8px;
    }
  }
}
.top-box {
  display: flex;
  justify-content: space-between;
  .right-label {
    .label {
      display: inline-block;
      background: rgba(73, 177, 108, 0.1);
      color: rgba(73, 177, 108, 1);
      font-size: 14px;
      border-radius: 4px;
      margin-left: 5px;
      line-height: 20px;
      padding: 0 5px;
    }
  }
}
.grid_item_top {
  display: flex;
  align-items: center;
}
.icon_box {
  background-color: rgb(35, 114, 235);
  border-radius: 4px;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.grid_item_top_icon {
  font-size: 16px;
  color: #fff;
}
.grid_item_top_title {
  font-size: 16px;
  font-weight: 600;
  margin-left: 10px;
}
.grid_item_middle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgb(249, 249, 250);
  padding: 10px 15px;
  margin-top: 10px;
}
.grid_item_middle_item {
  text-align: center;
  width: 30%;
}
.middle_num {
  margin-top: 10px;
  font-weight: 600;
  font-size: 14px;
  color: #262626;
}
.middle_title {
  font-size: 12px;
  color: #595959;
}
.line {
  width: 1px;
  height: 30px;
  background-color: rgb(255, 255, 255);
  border: 1px solid rgb(218, 220, 224);
}
.grid_item_bottom {
  margin-top: 8px;
  font-size: 12px;
}
.grid_item_bottom_item {
  margin-top: 5px;
  .branch-detail {
    color: #4886f8;
    margin-left: 5px;
  }
}
.bottom_item_left {
  color: rgb(140, 140, 140);
}
.myDialog {
  .content {
    padding: 5px 15px;
    .my-title {
      font-size: 14px;
      color: rgba(0, 0, 0, 0.45);
    }
    .item {
      margin: 8px 0;
      .index {
        display: inline-block;
        width: 16px;
        height: 16px;
        background: rgba(22, 132, 252, 1);
        color: #fff;
        border-radius: 4px;
        font-size: 14px;
        text-align: center;
        line-height: 16px;
      }
      .branch-name {
        font-size: 14px;
        color: rgba(0, 0, 0, 0.85);
        margin-left: 5px;
      }
    }
    .grid-box {
      max-height: 150px;
      overflow-y: auto;
    }
  }
  ::v-deep .van-button__content {
    color: #666;
  }
}
</style>