SellAuth.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div>
  3. <search-cpn
  4. v-bind="searchConfig"
  5. @handleSearch="handleSearchEvent"
  6. @clearEvent="handleClearEvent"
  7. >
  8. <!-- 位置 -->
  9. <template #location="scope">
  10. <el-cascader
  11. :options="options"
  12. v-model="searchForm2.location"
  13. :props="{ checkStrictly: true }"
  14. :placeholder="scope.item.placeholder"
  15. style="width: 100%"
  16. clearable
  17. >
  18. </el-cascader>
  19. </template>
  20. </search-cpn>
  21. <br/>
  22. <new-table :title="'牧场列表'" :list-data="tableData" :table-items="tableItems" :shows="showsItems">
  23. <template #location="scope">
  24. <span v-location="{ data: scope.row.location }"></span>
  25. </template>
  26. <template #sellStatus="scope">
  27. <el-switch v-model="scope.row.sellStatus" @change="setSellStatus(scope.row, $event)"></el-switch>
  28. </template>
  29. </new-table>
  30. </div>
  31. </template>
  32. <script>
  33. import SearchCpn from "../../components/search-cpn/SearchCpn";
  34. import NewTable from "../../components/newTable/NewTable";
  35. import { regionData } from "element-china-area-data";
  36. import { baseFarmList, baseFarmEdit } from "../../utils/apis/basic-data/archivesAdmin";
  37. export default {
  38. name: "SellAuth",
  39. components: {
  40. SearchCpn,
  41. NewTable
  42. },
  43. data() {
  44. return {
  45. searchConfig: {},
  46. searchForm1: {
  47. farmName: undefined,
  48. type: 2,
  49. },
  50. searchForm2: {
  51. location: [],
  52. },
  53. formItemProp: [
  54. {
  55. label: '名称:',
  56. type: 'input',
  57. field: 'farmName',
  58. placeholder: '请输入名称',
  59. },
  60. {
  61. label: '位置:',
  62. type: 'custom',
  63. field: 'location',
  64. slotName: 'location',
  65. placeholder: '请选择位置'
  66. },
  67. ],
  68. options: regionData,
  69. searchForm: {
  70. farmName: undefined,
  71. type: 2,
  72. location: undefined,
  73. },
  74. pageNo: 1,
  75. pageSize: 20,
  76. tableData: [],
  77. tableItems: [
  78. {
  79. prop: 'farmName',
  80. label: "牧场名称",
  81. slotName: 'farmName'
  82. },
  83. {
  84. prop: 'location',
  85. label: "牧场位置",
  86. slotName: 'location'
  87. },
  88. {
  89. prop: 'sellStatus',
  90. label: '是否禁用售猪',
  91. slotName: 'sellStatus'
  92. }
  93. ],
  94. showsItems: {
  95. // showSelect: true
  96. },
  97. }
  98. },
  99. created() {
  100. this.searchConfig = { formItemProp: this.formItemProp, searchForm: this.searchForm1 };
  101. },
  102. methods: {
  103. handleSearchEvent(value) {
  104. this.searchForm = {
  105. ...value,
  106. location: this.searchForm2.location.join(","),
  107. }
  108. this.initBaseFarm()
  109. },
  110. handleClearEvent() {
  111. this.searchForm2.location = [];
  112. },
  113. initBaseFarm() {
  114. let params = {
  115. current: this.pageNo,
  116. size: this.pageSize,
  117. ...this.searchForm
  118. }
  119. baseFarmList(params).then(res => {
  120. if(res.code === 10000) {
  121. this.tableData = res.data.records
  122. }
  123. })
  124. },
  125. setSellStatus(data, e) {
  126. console.log(data, e)
  127. let params = {
  128. sellStatus: e,
  129. id: data.id
  130. }
  131. baseFarmEdit(params).then(res => {
  132. console.log(res)
  133. if(res.code === 10000) {
  134. this.$message.success('修改成功!')
  135. } else {
  136. this.$message.error('修改失败')
  137. }
  138. })
  139. }
  140. },
  141. mounted() {
  142. this.initBaseFarm()
  143. }
  144. }
  145. </script>
  146. <style scoped>
  147. </style>