zouyu
2024-02-29 363678a54142e62fdd4ca39a0db5c54af1a704dc
src/views/plan/customerorder/index.vue
@@ -8,6 +8,7 @@
        :prelang="prelang"
        :options="options"
        :ajaxFun="ajaxFun"
        :toolbarMaxLength="4"
        :paramArr="type"
        ref="customerOrderTable"
      >
@@ -241,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'
@@ -285,6 +311,9 @@
export default {
  data() {
    return {
      interrelatedOrderId: null,
      interrelatedOrderData: [],
      showInterrelatedOrderDialog: false,
      uniqueStateArr: [],
      dataForm: {
        selectTime: null,
@@ -400,7 +429,7 @@
        isRefresh: true, // 是否显示刷新按钮
        isShowHide: true, // 是否显示显影按钮H
        isSearch: true, // 高级查询按钮
        defaultOrderBy: { column: 'createTime', direction: 'desc' },
        defaultOrderBy: { column: 'placeOrderDate', direction: 'desc' },
        cancelRunCreated: true
      },
      table: {
@@ -497,7 +526,7 @@
          {
            minWidth: '120',
            prop: 'isAudit',
            label: '审核状态',
            label: 'PLM审核状态',
            sort: true,
            isTrue: true,
            isSearch: true,
@@ -507,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',
@@ -655,6 +688,25 @@
          //   fun: this.packageExportHandle
          // },
          {
            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',
@@ -673,8 +725,8 @@
        operatorConfig: {
          fixed: 'right',
          label: '操作',
          width: 100,
          minWidth: 100
          width: 200,
          minWidth: 200
        }
      },
      addOrUpdateVisible: false,
@@ -780,7 +832,8 @@
        }
      ],
      showSalesPartBatch: false,
      addOrUpdateEescVisible: false
      addOrUpdateEescVisible: false,
      isPassList: [{label:'未通过',value: false},{label: '通过',value: true}]
    }
  },
  components: {
@@ -812,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() {
@@ -855,6 +919,20 @@
        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: '主生产计划',
@@ -863,15 +941,59 @@
        permitArr: []
      })
    }
    this.table.toolbar.push({
        text: '下载Word',
        disabled: false,
        type: 'primary',
        fun: this.downloadWord,
        permitArr: ['03plan','04planed'],
    })
  },
  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)
@@ -879,8 +1001,20 @@
            this.$message.error("请选择一条数据")
            return
        }
        downloadWordFile(ids).then(res=>{
            transform(res)
        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);
        })
@@ -949,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)
@@ -960,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)
      })
    },
    // 打开日期选择框
@@ -1037,7 +1190,8 @@
            }
          })
          if (flag) {
            checkOA(this.multipleSelection.map((e) => e.id)).then((res) => {
            checkOA(this.multipleSelection.map((e) => e.id),{}).then((res) => {
              if (!res.data.data.success) {
                this.$confirm(`${res.data.data.message}`, '提示', {
                  confirmButtonText: '确定',
@@ -1391,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) {