zouyu
2024-02-29 363678a54142e62fdd4ca39a0db5c54af1a704dc
src/views/plan/customerorder/index.vue
@@ -8,26 +8,11 @@
        :prelang="prelang"
        :options="options"
        :ajaxFun="ajaxFun"
        :toolbarMaxLength="4"
        :paramArr="type"
        ref="customerOrderTable"
      >
        <template #toolbar>
          <!-- <el-dropdown
            v-if="permissions.customerorder_state_change"
            @command="handleCommand"
          >
            <el-button>
              状态改变<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                :command="item.command"
                v-for="item in stateTagArr"
                :disabled="item.disabled">
                {{ item.label }}
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown> -->
          <el-dropdown
            v-if="permissions.customerorder_doc_relate"
            @command="documentHandle"
@@ -38,10 +23,10 @@
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                :key="index"
                :command="item.command"
                v-for="item in documentTagArr"
                :disabled="item.disabled"
              >
                v-for="(item,index) in documentTagArr"
                :disabled="item.disabled">
                {{ item.label }}
              </el-dropdown-item>
            </el-dropdown-menu>
@@ -57,42 +42,21 @@
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                :key="index"
                :command="item.command"
                v-for="item in commitStateTagArr"
                v-for="(item,index) in commitStateTagArr"
                :disabled="item.disabled"
                >{{ item.label }}</el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>
          <!-- <el-button
            v-if="permissions.customerorder_push_otc"
            style="margin-left:10px;"
            type="primary"
            @click="pushOtc"
            >推送ERP</el-button
          > -->
          <!-- <el-button
            style="margin-left:10px;"
            type="primary"
            @click="importOutPutBatch"
            >导入产出批次</el-button
          > -->
          <el-button
            style="margin-left:10px;"
            type="primary"
            @click="exportStandBook"
            >导出台账</el-button
          >
          <el-button
            v-if="permissions.plan_customerorder_return"
            style="margin-left:10px;"
            type="primary"
            @click="returnOrder"
            >订单退回</el-button
          >
            @click="()=>exportDialogVisible=true"
            >导出台账</el-button>
        </template>
      </ttable>
      <!-- 弹窗, 日期选择 -->
      <ConfirmPullCustomerorder
        v-if="showPullCustomerOrderVisible"
@@ -189,6 +153,26 @@
        </span>
        <span slot="footer" class="dialog-footer"> </span>
      </el-dialog>
      <!-- 导出 -->
      <el-dialog title="导出台账" :visible.sync="exportDialogVisible" width="20%">
        <div style="display: flex;justify-content: center">
          <el-form :model="dataForm" :inline="true" :rules="dataRule" ref="exportForm" class="l-mes">
            <el-form-item label="日期" prop="exportTime">
              <el-date-picker
                v-model="dataForm.exportTime"
                type="datetime"
                style="width:100%"
                placeholder="选择日期时间"
                value-format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
            </el-form-item>
          </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="exportDialogVisible=false">取 消</el-button>
        <el-button type="primary" @click="exportStandBook">确 定</el-button>
      </span>
    </el-dialog>
      <!-- 箱码信息导出 -->
      <el-dialog
        title="箱码信息导出"
@@ -258,10 +242,35 @@
        <el-button type="primary" @click="startSync">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
    title="已关联销售订单"
    :visible.sync="showInterrelatedOrderDialog"
    width="60%">
        <el-table border height="100" :data="interrelatedOrderData">
            <el-table-column type="index" align="center" label="序号"></el-table-column>
            <el-table-column prop="contractNo" show-overflow-tooltip align="center" label="合同编号"></el-table-column>
            <el-table-column prop="entityName" show-overflow-tooltip align="center" label="工程名称"></el-table-column>
            <el-table-column prop="sourceId" show-overflow-tooltip align="center" label="添加来源">
                <template scope="scope">
                    <el-tag v-if="scope.row.sourceId == 0" type="success">同步</el-tag>
                    <el-tag v-if="scope.row.sourceId == 1" type="info">手动</el-tag>
                </template>
            </el-table-column>
            <el-table-column prop="placeOrderDate" show-overflow-tooltip align="center" label="下单日期"></el-table-column>
            <el-table-column prop="customerName" show-overflow-tooltip align="center" label="客户名称"></el-table-column>
            <el-table-column prop="coState" min-width="100" show-overflow-tooltip align="center" label="销售订单状态"></el-table-column>
            <el-table-column prop="partNo" show-overflow-tooltip align="center" label="产品编号"></el-table-column>
            <el-table-column prop="productName" show-overflow-tooltip align="center" label="产品名称"></el-table-column>
            <el-table-column prop="productType" show-overflow-tooltip align="center" label="隶属品牌"></el-table-column>
            <el-table-column prop="otcUnit" show-overflow-tooltip align="center" label="单位"></el-table-column>
            <el-table-column prop="buyQtyDue" show-overflow-tooltip align="center" label="数量"></el-table-column>
        </el-table>
    </el-dialog>
  </div>
</template>
<script>
import {interrelatedOrder,getInterrelatedOrder,checkHanderOrder} from '@/api/plan/customerOrderInterrelated'
import ConfirmPullCustomerorder from './confirm-pull-customerorder'
import TableForm from './customerorder-form'
import TableFormDEesc from './customerorder-form-desc'
@@ -289,7 +298,8 @@
  exportCustomerOrder,
  exportCustomerOrderSplit,
  syncOrder,
  dropByContractNo
  dropByContractNo,
  downloadWordFile
} from '../../../api/plan/customerorder'
import DocumentTable from '@/views/common/document.vue'
import { remote } from '@/api/admin/dict'
@@ -301,10 +311,17 @@
export default {
  data() {
    return {
      interrelatedOrderId: null,
      interrelatedOrderData: [],
      showInterrelatedOrderDialog: false,
      uniqueStateArr: [],
      dataForm: {
        selectTime: null
        selectTime: null,
        exportTime: null
      },
      dataRule: {},
      dataRule: {
        exportTime:[{required:true,message:'导出日期不能为空',trigger:'change'}]
      },
      pickerOptions: {
        onPick: ({ maxDate, minDate }) => {
          if (minDate && this.pickerMinDate) {
@@ -323,6 +340,7 @@
          return false
        }
      },
      exportDialogVisible: false,
      syncDateVisible: false,
      syncDate: [],
      showCustomerorderReturn: false,
@@ -411,7 +429,7 @@
        isRefresh: true, // 是否显示刷新按钮
        isShowHide: true, // 是否显示显影按钮H
        isSearch: true, // 高级查询按钮
        defaultOrderBy: { column: 'createTime', direction: 'desc' },
        defaultOrderBy: { column: 'placeOrderDate', direction: 'desc' },
        cancelRunCreated: true
      },
      table: {
@@ -450,7 +468,7 @@
            searchInfoType: 'text'
          },
          {
            minWidth: '120',
            minWidth: '100',
            prop: 'sourceId',
            label: '添加来源',
            isTag: true,
@@ -508,7 +526,7 @@
          {
            minWidth: '120',
            prop: 'isAudit',
            label: '审核状态',
            label: 'PLM审核状态',
            sort: true,
            isTrue: true,
            isSearch: true,
@@ -518,15 +536,19 @@
              return this.isAuditList
            }
          },
          // {
          //   minWidth: '80',
          //   prop: 'sourceId',
          //   label: '订单来源',
          //   sort: true,
          //   isTrue: true,
          //   isSearch: true,
          //   searchInfoType: 'text'
          // },
          {
            minWidth: '120',
            prop: 'isPass',
            label: '审核通过状态',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'select',
            formatter: this.checkIsPass,
            optList: () => {
                return this.isPassList
            }
          },
          {
            minWidth: '120',
            width: '100px',
@@ -551,7 +573,7 @@
            minWidth: '120',
            width: '100px',
            prop: 'productType',
            label: '产品类型',
            label: '隶属品牌',
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
@@ -666,7 +688,26 @@
          //   fun: this.packageExportHandle
          // },
          {
            text: '作废',
            text: '审核',
            type: 'text',
            size: 'small',
            fun: this.checkHandOrder,
            showFun: (row)=>{return row.sourceId==='1'},
            show: {
              val: [
                false,
              ],
              key: 'isPass'
            }
          },
          {
            text: '已关联订单',
            type: 'text',
            size: 'small',
            fun: this.showInterrelatedOrder,
          },
          {
            text: '删除',
            type: 'text',
            size: 'small',
            fun: this.cancelHandle,
@@ -684,8 +725,8 @@
        operatorConfig: {
          fixed: 'right',
          label: '操作',
          width: 100,
          minWidth: 100
          width: 200,
          minWidth: 200
        }
      },
      addOrUpdateVisible: false,
@@ -745,10 +786,10 @@
      ],
      sourceIdList: [{
        label: '同步',
        value: '0'
        value: "0"
      },{
        label: '手动',
        value: '1'
        value: "1"
      }],
      stockVisible: false,
      partName: null,
@@ -791,7 +832,8 @@
        }
      ],
      showSalesPartBatch: false,
      addOrUpdateEescVisible: false
      addOrUpdateEescVisible: false,
      isPassList: [{label:'未通过',value: false},{label: '通过',value: true}]
    }
  },
  components: {
@@ -811,6 +853,11 @@
    ...mapGetters(['permissions'])
  },
  watch: {
    exportDialogVisible(newVal) {
      if (!newVal) {
        this.$refs.exportForm.resetFields()
      }
    },
    coState: {
      handler(newValue, oldValue) {
        if (newValue) {
@@ -818,6 +865,17 @@
        }
      },
      immediate: true
    },
    interrelatedOrderId(newVal){
        if(newVal){
            getInterrelatedOrder(newVal).then(res=>{
                if(res.status===200){
                    this.interrelatedOrderData = res.data.data
                }
            }).catch(error=>{
                console.error(error)
            })
        }
    }
  },
  mounted() {
@@ -826,36 +884,6 @@
  created() {
    // this.getManufactureAttrs()
    this.getTitles()
    /**
     * {
            text: '获取销售订单',
            type: 'primary',
            fun: this.pullCustomerOrder,
            disabled: false,
            permitArr: []
          },
          {
            text: '获取IFS行号',
            type: 'primary',
            fun: this.pullIfsLineNo,
            disabled: false,
            permitArr: [],
            loading: false
          },
          {
            text: '提交审核',
            type: 'primary',
            fun: this.auditCustomerOrder,
            disabled: false,
            permitArr: [],
            loading: false
          },
          {
            text: '主生产计划',
            disabled: false,
            fun: this.masterPlanHandle
          }
     */
    this.table.toolbar.push({
      text: '新增销售订单',
      type: 'primary',
@@ -863,14 +891,6 @@
      disabled: false,
      permitArr: []
    })
    // this.table.toolbar.push({
    //   text: '同步ERP',
    //   type: 'primary',
    //   fun: this.syncERP,
    //   loading: false,
    //   disabled: false,
    //   permitArr: []
    // })
    if (this.permissions.customerorder_from_otc) {
      this.table.toolbar.push({
        text: '获取销售订单',
@@ -880,43 +900,125 @@
        permitArr: []
      })
    }
    // if (this.permissions.customerorder_ifs_line) {
    //   this.table.toolbar.push({
    //     text: '获取ERP行号',
    //     type: 'primary',
    //     fun: this.pullIfsLineNo,
    //     disabled: false,
    //     permitArr: [],
    //     loading: false
    //   })
    // }
    if (this.permissions.customerorder_submit_oa) {
      // this.table.toolbar.push({
      //   text: '提交审核',
      //   type: 'primary',
      //   fun: this.auditCustomerOrder,
      //   disabled: false,
      //   permitArr: [],
      //   loading: false
      // })
      this.table.toolbar.push({
        text: '提交审核',
        type: 'primary',
        fun: this.auditCustomerOrder,
        disabled: false,
        permitArr: [],
        loading: false
      })
    }
    if (this.permissions.customerorder_set_salesparts) {
      this.table.toolbar.push({
        text: '设置销售件',
        type: 'primary',
        fun: this.setSalesPart,
        disabled: false
        disabled: false,
        permitArr: []
      })
    }
    this.table.toolbar.push({
        text: '下载Word',
        disabled: false,
        type: 'primary',
        fun: this.downloadWord,
        permitArr: ['03plan','04planed'],
    })
    this.table.toolbar.push({
        text: '关联订单',
        disabled: false,
        type: 'primary',
        fun: this.interrelatedOrderFun,
        permitArr: [],
    })
    if (this.permissions.customerorder_create_masterplan) {
      this.table.toolbar.push({
        text: '主生产计划',
        disabled: false,
        fun: this.masterPlanHandle
        fun: this.masterPlanHandle,
        permitArr: []
      })
    }
  },
  methods: {
    checkHandOrder(val){
        this.$confirm('确认审核通过该销售订单吗?', '提示', {
          confirmButtonText: '通过',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            checkHanderOrder(val).then(res=>{
            if(res.status===200){
                this.$message.success("审核通过")
                this.getData()
            }
          }).catch(error=>{
            console.error(error)
          })
        }).catch(() => {});
    },
    interrelatedOrderFun(){
        if(this.multipleSelection.length!=2){
            this.$message.error("请选择两条销售订单")
            return
        }
        let autoId = null
        let handId = null
        this.multipleSelection.forEach(ele=>{
            if(ele.sourceId==0){
                autoId = ele.id
            }else if(ele.sourceId==1){
                handId = ele.id
            }
        })
        if(autoId==null || handId==null){
            this.$message.error("添加来源须为手动和同步")
            return
        }
        interrelatedOrder({
            customerOrderAutoId: autoId,
            customerOrderHandId: handId
        }).then(res=>{
            if(res.status===200){
                this.$message.success("关联成功")
            }
        }).catch(error=>{
            console.error(error)
        })
    },
    //展示已关联订单
    showInterrelatedOrder(currentOrder){
        this.interrelatedOrderId = currentOrder.id
        this.showInterrelatedOrderDialog = true
    },
    //下载word
    downloadWord(){
        let ids = this.multipleSelection.map(ele=>ele.id)
        if(ids.length<1){
            this.$message.error("请选择一条数据")
            return
        }
        downloadWordFile(ids).then(response=>{
          // 处理返回的文件流
          const blob = response.data
          const link = document.createElement('a')
          link.href = URL.createObjectURL(blob)
          const disposition = response.headers["content-disposition"]
          let temp = disposition.substring(disposition.lastIndexOf('=') + 1)
          link.download = decodeURI(temp)
          document.body.appendChild(link)
          link.click()
          window.setTimeout(function() {
            URL.revokeObjectURL(blob)
            document.body.removeChild(link)
          }, 0)
        }).catch(error=>{
            console.error(error);
        })
    },
    getOtcPartSyncOptionList() {
      return this.otcPartSyncOptionList
    },
@@ -925,7 +1027,7 @@
      queryParam.push(
        Object.assign({
          prop: 'coState',
          searchInfoType: 'select',
          searchInfoType: 'select'
          // propVal: '01partUnCheck'
          // propVal: '02technologyUnCheck'
        })
@@ -946,7 +1048,6 @@
    },
    // 创建主生产计划
    masterPlanHandle() {
      console.log(this.multipleSelection);
      if (this.multipleSelection && this.multipleSelection.length > 0) {
        if (this.judgeCoState(this.multipleSelection)) {
          // 判断一下剩余数量是否大于0
@@ -982,6 +1083,18 @@
        this.$message.error('请选择销售订单')
      }
    },
    checkIsPass(row, column, cellValue){
        this.isPassList.forEach((obj) => {
            if (obj.value === cellValue) {
                if(obj.value){
                    cellValue = "<span style='color:#34BD66;'>"+obj.label+"</span>"
                }else{
                    cellValue = "<span style='color:#E84738;'>"+obj.label+"</span>"
                }
            }
        })
        return cellValue
    },
    formatDutyDate(row, column, cellValue) {
      if (cellValue) {
        const dutyDateList = /\d{4}-\d{1,2}-\d{1,2}/g.exec(cellValue)
@@ -993,16 +1106,23 @@
    },
    // 新增 / 修改
    addOrUpdateHandle(row) {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(row ? row.id : row)
      })
      if(row.isPass){
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
            this.$refs.addOrUpdate.init(row ? row.id : row)
        })
      }else{
        this.addSampleVisible = true
        this.$nextTick(() => {
            this.$refs.addSampleForm.init(row ? row.contractNo : null)
        })
      }
    },
    // 新增样品订单
    addSampleCustomerOrder() {
      this.addSampleVisible = true
      this.$nextTick(() => {
        this.$refs.addSampleForm.init(0)
        this.$refs.addSampleForm.init(null)
      })
    },
    // 打开日期选择框
@@ -1063,15 +1183,15 @@
          let flag = true
          const ids = []
          this.multipleSelection.forEach((item) => {
            if (item.salesPartNo != null && item.salesPartNo !== '') {
            if (item.partNo != null && item.partNo !== '') {
              ids.push(item.id)
            } else {
              flag = false
            }
          })
          if (flag) {
            checkOA(this.multipleSelection.map((e) => e.id)).then((res) => {
              console.log(res)
            checkOA(this.multipleSelection.map((e) => e.id),{}).then((res) => {
              if (!res.data.data.success) {
                this.$confirm(`${res.data.data.message}`, '提示', {
                  confirmButtonText: '确定',
@@ -1120,7 +1240,6 @@
    // 箱码信息导出
    packageExportHandle(row) {
      console.log(row.otcQuantity)
      if (row.otcQuantity) {
        this.packageExport.visible = true
        this.packageExport.form = {
@@ -1157,13 +1276,13 @@
    },
    // 作废
    cancelHandle(row) {
      this.$confirm('是否确认作废销售订单号为' + row.customerOrderNo + '提示', {
      this.$confirm('确认作废id为【' + row.id + '】的数据?','提示' , {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        closeOnClickModal: false,
        type: 'warning'
      }).then(() => {
        dropByContractNo(row.customerOrderNo).then((res) => {
        dropByContractNo({id:row.id}).then((res) => {
          if (res.data.code === 0) {
            this.$message.success('作废成功')
            this.getData()
@@ -1234,6 +1353,21 @@
          this.stateTagArr[i].disabled = false
        } else {
          this.stateTagArr[i].disabled = true
        }
      }
      // 循环表头按钮,判断每个按钮的permitArr是否完全包含选中状态,若完全包含,则按钮亮,否则按钮灰
      var toolbar = this.table.toolbar
      for (var j = 0; j < toolbar.length; j++) {
        if (
          uniqueStateArr.every((val) =>
            toolbar[j].permitArr.length <= 0
              ? true
              : toolbar[j].permitArr.includes(val)
          )
        ) {
          toolbar[j].disabled = false
        } else {
          toolbar[j].disabled = true
        }
      }
      this.multipleSelection = val
@@ -1411,6 +1545,10 @@
      } else {
        if (this.judgeCoState(this.multipleSelection)) {
          if (event == 'RELEVANCE') {
            if(!this.multipleSelection[0].isPass){
                this.$message.error("请先审核通过,再关联工艺文件")
                return
            }
            const firstPartNo = this.multipleSelection[0].partNo
            this.multipleSelection.forEach((item) => {
              if (item.isDocument) {
@@ -1419,7 +1557,7 @@
                  '存在销售订单已关联工艺文件,如需更改,请先解除关联'
                )
              }
              if (item.salesPartNo == null || item.salesPartNo === '') {
              if (item.partNo == null || item.partNo === '') {
                status = true
                this.$message.error('存在销售订单未绑定销售件,请先绑定')
              }
@@ -1549,7 +1687,6 @@
    },
    // 导出台账
    exportStandBook() {
      // console.log(this.$refs.customerOrderTable.getQueryParam(),"SSS")
      // if (this.multipleSelection.length > 0) {
      //   let ids = ''
      //   this.multipleSelection.forEach((item) => {
@@ -1574,11 +1711,18 @@
      // } else {
      //   this.$message.error('请选择至少一条销售订单')
      // }
      exportCustomerOrder(this.$refs.customerOrderTable.getQueryParam())
        .then((response) => {
          transform(response)
        })
        .catch(() => {})
      this.$refs['exportForm'].validate(valid => {
        if(valid){
          const exportTime = this.dataForm.exportTime
          let queryParam=this.$refs.customerOrderTable.getQueryParam();
          queryParam.selectTime = exportTime
          exportCustomerOrder(queryParam)
            .then((response) => {
              transform(response)
            })
            .catch(() => {})
        }
      })
    },
    setSalesPart() {
      if (this.multipleSelection.length > 0) {