123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <template>
- <div>
- <search-cpn
- v-bind="searchConfig"
- @handleSearch="handleSearchEvent"
- @clearEvent="handleClearEvent"
- >
- <!-- 位置 -->
- <template #location="scope">
- <el-cascader
- :options="options"
- v-model="searchForm2.location"
- :props="{ checkStrictly: true }"
- :placeholder="scope.item.placeholder"
- style="width: 100%"
- clearable
- >
- </el-cascader>
- </template>
- </search-cpn>
- <br/>
- <new-table :title="'牧场列表'" :list-data="tableData" :table-items="tableItems" :shows="showsItems">
- <template #location="scope">
- <span v-location="{ data: scope.row.location }"></span>
- </template>
- <template #sellStatus="scope">
- <el-switch v-model="scope.row.sellStatus" @change="setSellStatus(scope.row, $event)"></el-switch>
- </template>
- </new-table>
- </div>
- </template>
- <script>
- import SearchCpn from "../../components/search-cpn/SearchCpn";
- import NewTable from "../../components/newTable/NewTable";
- import { regionData } from "element-china-area-data";
- import { baseFarmList, baseFarmEdit } from "../../utils/apis/basic-data/archivesAdmin";
- export default {
- name: "SellAuth",
- components: {
- SearchCpn,
- NewTable
- },
- data() {
- return {
- searchConfig: {},
- searchForm1: {
- farmName: undefined,
- type: 2,
- },
- searchForm2: {
- location: [],
- },
- formItemProp: [
- {
- label: '名称:',
- type: 'input',
- field: 'farmName',
- placeholder: '请输入名称',
- },
- {
- label: '位置:',
- type: 'custom',
- field: 'location',
- slotName: 'location',
- placeholder: '请选择位置'
- },
- ],
- options: regionData,
- searchForm: {
- farmName: undefined,
- type: 2,
- location: undefined,
- },
- pageNo: 1,
- pageSize: 20,
- tableData: [],
- tableItems: [
- {
- prop: 'farmName',
- label: "牧场名称",
- slotName: 'farmName'
- },
- {
- prop: 'location',
- label: "牧场位置",
- slotName: 'location'
- },
- {
- prop: 'sellStatus',
- label: '是否禁用售猪',
- slotName: 'sellStatus'
- }
- ],
- showsItems: {
- // showSelect: true
- },
- }
- },
- created() {
- this.searchConfig = { formItemProp: this.formItemProp, searchForm: this.searchForm1 };
- },
- methods: {
- handleSearchEvent(value) {
- this.searchForm = {
- ...value,
- location: this.searchForm2.location.join(","),
- }
- this.initBaseFarm()
- },
- handleClearEvent() {
- this.searchForm2.location = [];
- },
- initBaseFarm() {
- let params = {
- current: this.pageNo,
- size: this.pageSize,
- ...this.searchForm
- }
- baseFarmList(params).then(res => {
- if(res.code === 10000) {
- this.tableData = res.data.records
- }
- })
- },
- setSellStatus(data, e) {
- console.log(data, e)
- let params = {
- sellStatus: e,
- id: data.id
- }
- baseFarmEdit(params).then(res => {
- console.log(res)
- if(res.code === 10000) {
- this.$message.success('修改成功!')
- } else {
- this.$message.error('修改失败')
- }
- })
- }
- },
- mounted() {
- this.initBaseFarm()
- }
- }
- </script>
- <style scoped>
- </style>
|