loulijun2021
2023-02-08 b52925db344afb86bbb9413d19e59c971f6eef73
src/views/cggl/cgdd.vue
@@ -0,0 +1,551 @@
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <div class="bodyTopButtonGroup" style="justify-content: space-between">
        <!--        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>-->
        <el-button
          v-waves
          icon="el-icon-refresh-right"
          @click="syncERP"
        >同步ERP
        </el-button>
        <!--        <el-button v-waves icon="el-icon-download" @click="upload">导入</el-button>-->
      </div>
      <div class="bodyTopFormGroup">
        <el-form
          ref="form"
          :model="form"
          label-width="100px"
          inline
          style="display: flex;"
        >
          <div class="elForm">
            <el-form-item label="订单状态" style="display: flex;">
              <el-select
                v-model="form.mesorderstus"
                :popper-append-to-body="false"
                filterable
                style="width: 200px"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in mesorderstusArr"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="订单编号" style="display: flex;">
              <el-input v-model="form.mesordercode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="采购供方" style=" display:flex;">
              <el-input v-model="form.OrgName" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="单据日期" style="display: flex;">
              <!--              <el-select v-model="form.orderdate" style="width: 200px" placeholder="请选择">-->
              <!--                <el-date-picker-->
              <!--                  v-model="form.orderdate"-->
              <!--                  style="width: 200px"-->
              <!--                  type="date"-->
              <!--                  placeholder="选择日期"-->
              <!--                />-->
              <!--              </el-select>-->
              <el-date-picker
                v-model="form.orderdate"
                style="width: 200px"
                type="date"
                placeholder="选择日期"
              />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="源单单号" style="display: flex;">
              <el-input v-model="form.sourceorder" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="部门信息" style="display: flex;">
              <el-cascader
                ref="cascader"
                filterable
                popper-class="elCascader"
                :options="deptcodeArr"
                :props="defaultProps"
                @change="cascaderChange"
              />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="创建人员" style="display: flex;">
              <el-input v-model="form.creatuser" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="创建时间" style="display: flex;">
              <el-date-picker
                v-model="form.createdate"
                style="width: 200px"
                type="date"
                placeholder="选择日期"
              />
            </el-form-item>
          </div>
          <div class="bodySearchReset" :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}">
            <el-button v-waves type="primary" icon="el-icon-search" @click="search">查询</el-button>
            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
          </div>
        </el-form>
        <div
          class="bodyTopFormExpand"
        >
          <svg-icon
            v-show="mouseHoverType==='mouseout'"
            style="cursor: pointer"
            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"
            @mouseenter="mouseHoverType=$event.type"
          />
          <svg-icon
            v-show="mouseHoverType==='mouseenter'"
            style="cursor: pointer"
            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"
            @click="isExpandForm=!isExpandForm"
            @mouseout="mouseHoverType=$event.type"
          />
        </div>
      </div>
      <div class="elTableDiv">
        <el-table
          ref="tableDataRef"
          class="tableFixed"
          :data="tableData"
          :height="isExpandForm?tableHeight:(tableHeight+40)+'px'"
          border
          :row-class-name="tableRowClassName"
          :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+40)+'px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @sort-change="sortChange"
        >
          <el-table-column
            prop="RowNum"
            width="50"
            fixed
            label="序号"
          />
          <el-table-column
            prop="status"
            label="订单状态"
            width="110"
            sortable="custom"
          />
          <el-table-column
            prop="orderdate"
            label="单据日期"
            sortable="custom"
            width="110"
          >
            <template slot-scope="{row}">
              <div v-if="row.orderdate">{{ row.orderdate.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="ordercode"
            label="订单编号"
            sortable="custom"
            width="160"
            show-tooltip-when-overflow
          />
          <el-table-column
            prop="deptname"
            label="部门名称"
            width="130"
            show-tooltip-when-overflow
            sortable="custom"
          />
          <el-table-column
            prop="customername"
            label="往来单位"
            sortable="custom"
            min-width="180"
            show-tooltip-when-overflow
          />
          <el-table-column
            prop="saleorderCode"
            label="源单单号"
            sortable="custom"
            width="160"
            show-tooltip-when-overflow
          />
          <el-table-column
            prop="acceptdate"
            label="预计到货日期"
            width="130"
            sortable="custom"
          >
            <template slot-scope="{row}">
              <div v-if="row.acceptdate">{{ row.acceptdate.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="lm_user"
            label="创建人员"
            sortable="custom"
            width="110"
          />
          <el-table-column
            prop="lm_date"
            label="创建时间"
            width="110"
            sortable="custom"
          >
            <template slot-scope="{row}">
              <div v-if="row.lm_date">{{ row.lm_date.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="auditoruser"
            label="审核人"
            width="110"
            sortable="custom"
          >
            <template slot-scope="{row}">
              <div v-if="row.auditoruser">{{ row.auditoruser }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="auditordate"
            label="审核时间"
            width="110"
            sortable="custom"
          >
            <template slot-scope="{row}">
              <div v-if="row.auditordate">{{ row.auditordate.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            label="操作"
            width="120"
            fixed="right"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-tooltip class="item" effect="dark" content="编辑" placement="top">
                  <i class="el-icon-edit-outline" @click="edit('edit',row)" />
                </el-tooltip>
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i class="el-icon-delete" @click="del(row)" />
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!--分页-->
      <pagination
        :total="total"
        :page.sync="form.page"
        :limit.sync="form.rows"
        align="right"
        layout="total,prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getPurchaseOrderSearch"
      />
    </div>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
import {
  AddUpdateOrganization,
  DeleteOrganization,
  OrganizationSearch,
  PrentOrganization,
  UserOrganization
} from '@/api/jcsz'
import clearAllChildren, { validateCode } from '@/utils/global'
import waves from '@/directive/waves'
import { SeaveSearchErpOrder, SeaveSearchErpPurchaseOrder } from '@/api/ErpSyncMes'
import { PurchaseOrderSearch } from '@/api/cggl'
export default {
  name: 'Zzjg',
  components: {
    Pagination
  },
  directives: { waves },
  data() {
    return {
      mouseHoverType: 'mouseout',
      isExpandForm: false,
      mainHeight: 0,
      tableHeight: 0,
      form: {
        mesorderstus: '', // 订单状态
        mesordercode: '', // 订单编号
        customercode: '', // 供方编号
        orderdate: '', // 单据日期
        sourceorder: '', // 源单单号
        deptcode: '', // 部门编码
        creatuser: '', // 创建人员
        createdate: '', // 创建时间
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      mesorderstusArr: [
        { label: '新订单', value: 'NEW' },
        { label: '部分到货', value: 'BINARIVE' },
        { label: '已到货', value: 'INARIVE' },
        { label: '部分入库', value: 'BINSTOG' },
        { label: '已入库', value: 'INSTOG' },
        { label: '已关闭', value: 'CLOSED' }
      ],
      total: 10,
      tableData: [],
      defaultProps: {
        checkStrictly: true,
        value: 'code',
        label: 'name',
        children: 'children'
      },
      deptcodeArr: [] // 部门信息
    }
  },
  created() {
    this.getPurchaseOrderSearch()
    this.getUserOrganization()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
  },
  methods: {
    async getPurchaseOrderSearch() {
      const res = await PurchaseOrderSearch(this.form)
      this.tableData = res.data
      this.total = res.count
    },
    // 排序改变时
    sortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.form.order = order
      this.form.prop = prop
      this.getPurchaseOrderSearch()
    },
    // 查询
    search() {
      this.getPurchaseOrderSearch()
    },
    // 重置
    reset() {
      this.form.mesorderstus = ''
      this.form.mesordercode = ''
      this.form.customercode = ''
      this.form.orderdate = ''
      this.form.sourceorder = ''
      this.form.deptcode = ''
      this.form.creatuser = ''
      this.form.createdate = ''
      this.$refs.cascader.checkedValue = ''// 级联选择器的清空
      this.getPurchaseOrderSearch()
    },
    // 获取部门信息
    async getUserOrganization() {
      const { data: res } = await UserOrganization()
      this.deptcodeArr = clearAllChildren(res)
      console.log(this.deptcodeArr, 888)
    },
    // 级联选择器改变事件
    cascaderChange(val) {
      this.form.deptcode = val[val.length - 1]
    },
    // 删除按钮
    async del(row) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteOrganization({ orgid: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            if (this.form.page > 1 && this.tableData.length === 1) {
              this.form.page--
            }
            this.getPurchaseOrderSearch()
          }
        })
      }).catch(() => {
        this.$message.info('已取消删除')
      })
    },
    // 同步ERP
    syncERP() {
      const loading = this.$loading({
        lock: true,
        text: '正在同步ERP,请稍等...',
        spinner: 'el-icon-loading',
        customClass: 'osloading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      SeaveSearchErpPurchaseOrder().then(res => {
        console.log(res, 11)
        if (res.code === '200') {
          setTimeout(() => {
            this.getPurchaseOrderSearch()
            loading.close()
            this.$message.success('同步成功!')
          }, 2000)
        }
        // else if (res.code === '300') {
        //   setTimeout(() => {
        //     loading.close()
        //     this.$message.error('同步失败!')
        //   }, 10000)
        // }
      })
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 85
        this.tableHeight = this.mainHeight - 255
        this.$refs.tableDataRef.doLayout()
      })
    },
    tableRowClassName({ row, rowIndex }) {
      return 'custom-row'
    }
  }
}
</script>
<!--公共页面样式-->
<style lang="scss" scoped>
$main_color: #42b983;
::v-deep .el-button--text{
  font-size: 14px ;
  cursor: pointer ;
}
.el-icon-share ,.el-icon-delete,.el-icon-edit-outline{
  color: $main_color;
  cursor: pointer;
}
.el-icon-edit-outline{
  margin-right: 15px;
}
::v-deep .el-button--primary, .el-button--default, .el-button--info {
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 15px;
}
::v-deep .el-button--primary {
  //background-color: $main_color !important;
}
::v-deep .el-button--default {
  background-color: #f8f8fa;
  border: none;
}
::v-deep .el-input__inner {
  height: 34px;
  line-height: 34px;
  //color: #a7a7a7;
}
::v-deep .el-dialog__body {
  padding: 20px 100px !important;
}
::v-deep .dialogVisibleRoles .el-dialog__body {
  padding: 20px 20px !important;
}
::v-deep .importPickerClass .el-dialog__body {
  padding: 20px 20px !important;
}
::v-deep .el-dialog__footer {
  display: flex;
  justify-content: flex-end;
}
::v-deep .el-table .caret-wrapper {
  transform: scale(0.8);
}
::v-deep .cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
::v-deep .el-table::before {
  height: 0;
}
::v-deep .el-table__body-wrapper {
  background-color: #f8f8fa;
}
::v-deep .el-table__body .el-table__row.hover-row td{
  background-color: #eaecef ;
}
::v-deep .el-form--inline .el-form-item__label {
  color: #a7a7a7;
}
.body ::v-deep .el-divider {
  border: 1px solid #eee;
  width: 99%;
  margin: 10px auto;
}
.body ::v-deep .el-form-item {
  margin-bottom: 0;
}
.userDialogVisible ::v-deep .el-form-item {
  margin-bottom: 0;
}
::v-deep .el-select__caret{
  display: flex;
  align-items: center;
  justify-content: center;
}
.tableFixed{
  ::v-deep .el-table__fixed-right{
    height: 100% !important;
  }
  ::v-deep .el-table__fixed{
    height: 100% !important;
  }
}
</style>
<style>
.el-table .custom-row {
  background: #f8f8fa;
}
</style>