廖井涛
2024-04-23 2f894921e5cf74910805f08a5e3180b68ac09e18
north-glass-erp/northglass-erp/src/views/sd/product/SelectProduct.vue
@@ -15,14 +15,14 @@
//监听玻璃类型改变
let productList = ref([])
let date=ref(['',''])
productGlassTypeStore.GlassType=['','']
let props = defineProps({
  rowIndex:{}
})
let glassType = ref([])
watch(productGlassTypeStore,(newVal,oldVal) => {
})
const getProduct = () => {
  request.post(`/product/1/100/${productGlassTypeStore.GlassType}`,filterData.value).then((res) => {
    if(res.code==200){
@@ -144,7 +144,28 @@
    ElMessage.warning(res.msg)
  }
})
//删除与编辑方法
const getTableRow =  (row,type) => {
  switch (type) {
    case 'edit': {
      router.push({path:'/main/product/createProduct',query:{id:row.id}})
      break
    }
    case 'delete': {
      request.post(`/product/deleteProductById/${row.id}`).then((res) => {
        if(res.code==200){
          //router.push("/main/product/selectProduct")
          router.go(0)
          ElMessage.success('删除成功')
        }else{
          ElMessage.warning(res.msg)
        }
      })
      break
    }
  }
}
@@ -153,6 +174,7 @@
const xGrid = ref()
const gridOptions = reactive({
  height:'100%',
  loading: true,
  border:  "full",//表格加边框
  keepSource: true,//保持源数据
@@ -184,8 +206,9 @@
  },
  columns:[
    {type:'expand',fixed:"left",slots: { content:'content' },width: 60},
    {type: 'seq',fixed:"left", title: '自序', width: 80 },
    {title: '操作', width: 110, slots: { default: 'button_slot' },fixed:"left"},
    {field:'state',title: '审核', width: 40, slots: { default: 'state' }},
    {type: 'seq',fixed:"left", title: '自序', width: 80 },
    {field: 'id', title: '编号',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: false},
    {field: 'productName', title: '名称',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: false},
    {field: 'basicGlassType.typeName', title: '所属类别',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: false},
@@ -197,9 +220,9 @@
  data:null,//表格数据
  toolbarConfig: {
    buttons: [],
    import: false,
    export: true,
    print: true,
    // import: false,
    // export: true,
    // print: true,
    zoom: true,
    custom: true
  },
@@ -207,7 +230,7 @@
    return[
      columns.map((column, columnIndex) => {
        if (columnIndex === 0) {
          return `页数:${pageNum}/${pageTotal.value}`
          return `${pageNum}/${pageTotal.value}`
        }
        return ''
@@ -250,8 +273,13 @@
  })
}
let emit = defineEmits([
    'getProductRow'
])
const emitParent = (row) => {
  emit('getProductRow', row)
}
/*后端返回结果多层嵌套展示*/
@@ -327,7 +355,7 @@
    <vxe-grid
        @filter-change="filterChanged"
        max-height="100%"
        height="100%"
        class="mytable-scrollbar"
        ref="xGrid"
        v-bind="gridOptions"
@@ -341,7 +369,7 @@
        <ul class="expand-wrapper">
          <li  v-for="(item,index) in gridOptions.columns" v-show="item.field!=undefined ">
            <span style="font-weight: bold">{{item.title+':  '}}</span>
            <span v-if="hasDecimal(item.field)">{{ row[item.field.split('.')[0]][item.field.split('.')[1]] }}</span>
            <span v-if="hasDecimal(item.field)">{{ row[item.field] }}</span>
            <span v-else>{{ row[item.field] }}</span>
          </li>
@@ -349,9 +377,16 @@
      </template>
      <!--左边固定显示的插槽-->
      <template #button_slot="{ row }">
      <template #button_slot="{ row }" v-if="!props.rowIndex">
        <el-button @click="getTableRow(row,'edit')" link type="primary" size="small">编辑</el-button>
        <el-button @click="getTableRow(row,'delete')" link type="primary" size="small">删除</el-button>
        <el-popconfirm @confirm="getTableRow(row,'delete')" title="确认删除产品?">
          <template #reference>
            <el-button  link type="primary" size="small">删除</el-button>
          </template>
        </el-popconfirm>
      </template>
      <template #button_slot="{ row }" v-else>
        <el-button @click="emitParent(row)" link type="primary" size="small">添加</el-button>
      </template>
      <template #num1_filter="{ column, $panel }">
@@ -361,7 +396,9 @@
          </div>
        </div>
      </template>
      <template #state="{ row,column}">
        <el-checkbox @click.native.prevent   :checked="row[column.field]===1"/>
      </template>
    </vxe-grid>