loulijun2021
2023-11-09 eb21013ed92b622cbccb8087a0d62bddd1ce7204
src/views/makeModel/processRoute.vue
@@ -45,7 +45,10 @@
              <el-input v-model="form.createuser" style="width: 200px" placeholder="请输入" />
            </el-form-item>
          </div>
          <div class="bodySearchReset" :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}">
          <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>
@@ -102,7 +105,21 @@
            :fixed="item.fixed?(item.fixed==='left'?'left':'right'):false"
          >
            <template slot-scope="{row}">
              <div v-if="!row[item.prop]">/</div>
              <div v-if="item.prop==='isrolepart'">
                <i
                  v-if="row[item.prop]!==''"
                  :style="{color:$store.state.settings.theme}"
                  class="el-icon-share"
                  @click="routeClick(row)"
                />
                <i
                  v-if="row[item.prop]===''"
                  style="color:rgb(180 ,181, 185)"
                  class="el-icon-share"
                  @click="routeClick(row)"
                />
              </div>
              <div v-else-if="item.prop==='enable'">
                <div v-if="row[item.prop]==='Y'">
                  <i class="el-icon-success" :style="{color:$store.state.settings.theme}" style="margin-right: 2px" />
@@ -113,7 +130,9 @@
                  否
                </div>
              </div>
              <div v-else-if="!row[item.prop]">/</div>
              <div v-else>{{ row[item.prop] }}</div>
            </template>
          </el-table-column>
@@ -196,10 +215,20 @@
                  />
                </el-tooltip>
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i :style="{color:$store.state.settings.theme}" class="el-icon-delete" style="margin-right:15px;" @click="del(row)" />
                  <i
                    :style="{color:$store.state.settings.theme}"
                    class="el-icon-delete"
                    style="margin-right:15px;"
                    @click="del(row)"
                  />
                </el-tooltip>
                <el-tooltip v-del-tab-index class="item" effect="dark" content="复制" placement="top">
                  <i :style="{color:$store.state.settings.theme}" class="el-icon-document-copy" style="cursor: pointer;color:#42b983" @click="copy('copy',row)" />
                  <i
                    :style="{color:$store.state.settings.theme}"
                    class="el-icon-document-copy"
                    style="cursor: pointer;color:#42b983"
                    @click="copy('copy',row)"
                  />
                </el-tooltip>
              </div>
            </template>
@@ -396,18 +425,155 @@
        </div>
      </span>
    </el-dialog>
    <el-dialog
      v-el-drag-dialog
      title="工艺路线绑定产品"
      :visible.sync="routerDialogVisible"
      width="1200px"
      :close-on-click-modal="false"
      top="12vh"
      class="userDialogVisible"
      @closed="handleCloseRouter"
      @close="handleCloseRouter"
    >
      <div class="bodyTopFormGroup" style="margin-bottom: 10px">
        <el-form
          ref="routerForm"
          :model="routerForm"
          label-width="100px"
          inline
          style="display: flex;"
        >
          <div class="elForm">
            <el-form-item label="物料编码" style=" display: flex;">
              <el-input v-model="routerForm.partcode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="物料名称" style=" display: flex;">
              <el-input v-model="routerForm.partname" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="物料规格" style=" display: flex;">
              <el-input v-model="routerForm.partspec" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="存货类型" style=" display: flex;">
              <el-cascader
                ref="cascader"
                :options="stocktypeArr"
                filterable
                :props="defaultProps"
                @change="val=>cascaderChange(val)"
              />
            </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="getInventoryFileSelect">查询</el-button>
            <el-button v-waves type="info" icon="el-icon-refresh" @click="resetRouter">重置</el-button>
          </div>
        </el-form>
      </div>
      <el-table
        ref="multipleTableRef"
        :data="routerTableData"
        border
        :row-class-name="tableRowClassName"
        highlight-current-row
        height="450"
        :header-cell-style="this.$headerCellStyle"
        :cell-style="this.$cellStyle"
        :row-key="getRowKey"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          type="selection"
          width="50"
          :reserve-selection="true"
          fixed
        />
        <!--        <el-table-column-->
        <!--          prop="RowNum"-->
        <!--          width="50"-->
        <!--          label="序号"-->
        <!--        />-->
        <el-table-column
          prop="partcode"
          label="产品编码"
        />
        <el-table-column
          prop="partname"
          label="产品名称"
        />
        <el-table-column
          prop="partspec"
          label="规格型号"
        >
          <template slot-scope="{row}">
            {{ row.partspec?row.partspec:'/' }}
          </template>
        </el-table-column>
        <el-table-column
          prop="stocktypename"
          label="存货类型"
        >
          <template slot-scope="{row}">
            {{ row.stocktypename?row.stocktypename:'/' }}
          </template>
        </el-table-column>
      </el-table>
      <!--分页-->
      <!--      <pagination-->
      <!--        :total="routerTotal"-->
      <!--        :page.sync="routerForm.page"-->
      <!--        :limit.sync="routerForm.rows"-->
      <!--        align="right"-->
      <!--        style="margin-top: 10px"-->
      <!--        layout="total ,prev, pager, next,sizes"-->
      <!--        popper-class="select_bottom"-->
      <!--        @pagination="getInventoryFileSelect"-->
      <!--      />-->
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="routerDialogVisibleCancel">取 消</el-button>
          <el-button
            v-waves
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="routerDialogVisibleConfirm"
          >确 定</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
import { AddUpdateRoute, DeleteRoute, RouteSearch, StepSelect, ViewRoute } from '@/api/makeModel'
import {
  AddUpdateRoute,
  DeleteRoute,
  InventoryFileSelect, RouteBatchPartSave,
  RouteSearch, RputeInventorySearch,
  StepSelect,
  StockTypeSelect,
  ViewRoute
} from '@/api/makeModel'
import { validateCode } from '@/utils/global'
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
import TableColumnSettings from '@/components/TableColumnSettings'
import { WorkShopSelect } from '@/api/deviceManager'
import { getCookie } from '@/utils/auth'
import arrayToTree from 'array-to-tree'
export default {
  name: 'GYLX',
@@ -506,9 +672,19 @@
        {
          minWidth: 110,
          width: false,
          prop: 'isrolepart',
          label: '关联产品',
          id: 9,
          show: true,
          fixed: false,
          sortable: true
        },
        {
          minWidth: 110,
          width: false,
          prop: 'lm_user',
          label: '创建人员',
          id: 9,
          id: 10,
          show: true,
          fixed: false,
          sortable: true
@@ -518,7 +694,7 @@
          width: false,
          prop: 'lm_date',
          label: '创建时间',
          id: 10,
          id: 11,
          show: true,
          fixed: false,
          sortable: true
@@ -565,19 +741,118 @@
        // Data: [
        //   { required: true, message: '请设置工艺', trigger: ['blur', 'change'] }
        // ]
      }
      },
      routerDialogVisible: false,
      routerForm: {
        partcode: '', // 物料编码
        partname: '', // 物料名称
        partspec: '', // 物料规格
        stocktypecode: '', // 存货类型编码
        materialtypecode: '', // 物料类型编码
        storehousecode: '' // 所属仓库编码
        // prop: 'lm_date', // 排序字段
        // order: 'desc', // 排序字段
        // page: 1, // 第几页
        // rows: 20 // 每页多少条
      },
      routerTableData: [],
      routerTotal: 10,
      stocktypeArr: [],
      defaultProps: {
        checkStrictly: true,
        expandTrigger: 'hover',
        value: 'code',
        label: 'name'
      },
      multipleSelection: [],
      selectedRouterCode: '',
      selectedisrolepart: ''
    }
  },
  created() {
    this.getRouteSearch()
    this.getWorkShopSelect()
    // this.getInventoryFileSelect()
    this.getStockTypeSelect()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
  },
  methods: {
    handleCloseRouter() {
      this.$refs.multipleTableRef.clearSelection()
    },
    async getInventoryFileSelect() {
      const res = await RputeInventorySearch(this.routerForm)
      this.routerTableData = res.data
      this.routerTotal = res.count
      this.$nextTick(() => {
        this.routerTableData.forEach((item, index) => {
          if (this.selectedisrolepart.split(',').includes(item.partcode)) {
            this.$refs.multipleTableRef.toggleRowSelection(this.routerTableData[index], true)
          }
        })
      })
    },
    async getStockTypeSelect() {
      const { data: res } = await StockTypeSelect()
      this.stocktypeArr = arrayToTree(res, {
        parentProperty: 'iparent_id',
        customID: 'code',
        childrenProperty: 'children'
      })
    },
    resetRouter() {
      this.routerForm.partcode = ''
      this.routerForm.partname = ''
      this.routerForm.partspec = ''
      this.routerForm.stocktypecode = ''
      this.routerForm.materialtypecode = ''
      this.routerForm.storehousecode = ''
      this.$refs.cascader.checkedValue = ''
      this.getInventoryFileSelect()
    },
    cascaderChange(val) {
      this.routerForm.stocktypecode = val[val.length - 1]
    },
    routeClick(row) {
      this.selectedRouterCode = row.code
      this.selectedisrolepart = row.isrolepart
      this.routerDialogVisible = true
      this.getInventoryFileSelect()
    },
    getRowKey(row) {
      return row.partcode
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    routerDialogVisibleCancel() {
      this.routerDialogVisible = false
    },
    async   routerDialogVisibleConfirm() {
      const data = {
        'routecode': this.selectedRouterCode,
        'routepart': this.multipleSelection.length > 0 ? this.multipleSelection.map(i => i.partcode).join(',') : ''
      }
      this.$store.state.app.buttonIsDisabled = true
      const res = await RouteBatchPartSave(data)
      if (res.code === '200') {
        this.routerDialogVisible = false
        this.$message.success('绑定成功!')
        await this.getRouteSearch()
        this.$store.state.app.buttonIsDisabled = false
      } else {
        this.$message.error('绑定失败!')
      }
    },
    // 获取所属车间下拉
    async getWorkShopSelect() {
      const { data: res } = await WorkShopSelect()
@@ -912,7 +1187,13 @@
      this.$nextTick(() => {
        res[0].Data.forEach((item, index) => {
          this.dynamicTags.push(
            { seq: item.seq, stepname: item.stepname, stepcode: item.stepcode, editDisabled: true, effect: index === res[0].Data.length - 1 ? 'dark' : 'light' }
            {
              seq: item.seq,
              stepname: item.stepname,
              stepcode: item.stepcode,
              editDisabled: true,
              effect: index === res[0].Data.length - 1 ? 'dark' : 'light'
            }
          )
          this.routeSelectedArr.push({
            stepcode: item.stepcode,