bfood.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="mod-role">
  3. <div class="rect rect-form">
  4. <el-form size="mini" :inline="true" :model="dataForm">
  5. <el-form-item>
  6. <el-input v-model="dataForm.ingredients" placeholder="饲料名称" clearable></el-input>
  7. </el-form-item>
  8. <el-form-item>
  9. <el-input v-model="dataForm.details" placeholder="详细信息" clearable></el-input>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-input v-model="dataForm.stage" placeholder="使用阶段" clearable></el-input>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button
  16. icon="el-icon-search"
  17. @click="getDataList()">
  18. 查 询
  19. </el-button>
  20. </el-form-item>
  21. </el-form>
  22. </div>
  23. <div class="rect rect-table">
  24. <el-form size="mini" :inline="true" :model="dataForm">
  25. <el-form-item>
  26. <el-button
  27. icon="el-icon-plus"
  28. v-if="isAuth('sys:role:save')"
  29. type="primary"
  30. @click="addOrUpdateHandle()">新 增</el-button>
  31. <el-button
  32. icon="el-icon-delete"
  33. v-if="isAuth('sys:role:delete')"
  34. type="danger"
  35. @click="deleteHandle()"
  36. :disabled="dataListSelections.length <= 0">删 除</el-button>
  37. </el-form-item>
  38. </el-form>
  39. <el-table
  40. :data="dataList"
  41. border
  42. stripe
  43. size="mini"
  44. height="540"
  45. v-loading="dataListLoading"
  46. @selection-change="selectionChangeHandle"
  47. style="width: 100%;"
  48. :header-cell-style="{background:'rgb(245,245,245)',color:'#000',height: '45px',fontSize: '13px',fontWeight: 'normal',borderBottom: '1px solid #ccc'}"
  49. :cell-style="{color: '#888',fontSize: '13px'}">
  50. <el-table-column
  51. type="selection"
  52. header-align="center"
  53. align="center">
  54. </el-table-column>
  55. <el-table-column
  56. prop="ingredients"
  57. header-align="center"
  58. align="center"
  59. label="饲料名称">
  60. </el-table-column>
  61. <el-table-column
  62. prop="details"
  63. header-align="center"
  64. align="center"
  65. label="详细信息">
  66. </el-table-column>
  67. <el-table-column
  68. prop="stage"
  69. header-align="center"
  70. align="center"
  71. label="使用阶段">
  72. </el-table-column>
  73. <el-table-column
  74. prop="remark"
  75. header-align="center"
  76. align="center"
  77. label="备注">
  78. </el-table-column>
  79. <el-table-column
  80. header-align="center"
  81. align="center"
  82. label="操作">
  83. <template slot-scope="scope">
  84. <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
  85. <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. <el-pagination
  90. @size-change="sizeChangeHandle"
  91. @current-change="currentChangeHandle"
  92. :current-page="pageIndex"
  93. :page-sizes="[10, 20, 50, 100]"
  94. :page-size="pageSize"
  95. :total="totalPage"
  96. layout="total, sizes, prev, pager, next, jumper">
  97. </el-pagination>
  98. <!-- 弹窗, 新增 / 修改 -->
  99. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  100. </div>
  101. </div>
  102. </template>
  103. <script>
  104. import AddOrUpdate from './bfood-add-or-update'
  105. export default {
  106. data () {
  107. return {
  108. dataForm: {
  109. ingredients: '',
  110. details: '',
  111. stage: ''
  112. },
  113. dataList: [],
  114. pageIndex: 1,
  115. pageSize: 10,
  116. totalPage: 0,
  117. dataListLoading: false,
  118. dataListSelections: [],
  119. addOrUpdateVisible: false
  120. }
  121. },
  122. components: {
  123. AddOrUpdate
  124. },
  125. activated () {
  126. this.getDataList()
  127. },
  128. methods: {
  129. // 获取数据列表
  130. getDataList () {
  131. this.dataListLoading = true
  132. this.$http({
  133. url: this.$http.adornUrl('/management/basefeedformula/list'),
  134. method: 'get',
  135. params: this.$http.adornParams({
  136. 'page': this.pageIndex,
  137. 'limit': this.pageSize,
  138. 'ingredients': this.dataForm.ingredients || undefined,
  139. 'details': this.dataForm.details || undefined,
  140. 'stage': this.dataForm.stage || undefined
  141. })
  142. }).then(({data}) => {
  143. console.log('这是饲料种类配方');
  144. console.log(data);
  145. if (data && data.code === 0) {
  146. this.dataList = data.page.list
  147. this.totalPage = data.page.totalCount
  148. } else {
  149. this.dataList = []
  150. this.totalPage = 0
  151. this.$message.error(data.msg)
  152. }
  153. this.dataListLoading = false
  154. })
  155. },
  156. // 每页数
  157. sizeChangeHandle (val) {
  158. this.pageSize = val
  159. this.pageIndex = 1
  160. this.getDataList()
  161. },
  162. // 当前页
  163. currentChangeHandle (val) {
  164. this.pageIndex = val
  165. this.getDataList()
  166. },
  167. // 多选
  168. selectionChangeHandle (val) {
  169. this.dataListSelections = val
  170. },
  171. // 新增 / 修改
  172. addOrUpdateHandle (id) {
  173. console.log(id);
  174. this.addOrUpdateVisible = true
  175. this.$nextTick(() => {
  176. this.$refs.addOrUpdate.init(id)
  177. })
  178. },
  179. // 删除
  180. deleteHandle (id) {
  181. var ids = id ? [id] : this.dataListSelections.map(item => {
  182. return item.id
  183. })
  184. let names = id? [this.dataList.filter(item => item.id === id)[0].ingredients]: this.dataListSelections.map(item => {
  185. return item.ingredients
  186. })
  187. this.$confirm(`确定${id ? '删除' : '批量删除'}饲料配方${names.join(',')}?`, '提示', {
  188. confirmButtonText: '确定',
  189. cancelButtonText: '取消',
  190. type: 'warning'
  191. }).then(() => {
  192. this.$http({
  193. url: this.$http.adornUrl('/management/basefeedformula/delete'),
  194. method: 'post',
  195. data: this.$http.adornData(ids, false)
  196. }).then(({data}) => {
  197. if (data && data.code === 0) {
  198. this.getDataList()
  199. this.$message({
  200. message: '操作成功',
  201. type: 'success',
  202. duration: 1500,
  203. // onClose: () => {
  204. // this.getDataList()
  205. // }
  206. })
  207. } else {
  208. this.$message.error(data.msg)
  209. }
  210. })
  211. }).catch(() => {})
  212. }
  213. }
  214. }
  215. </script>
  216. <style scoped>
  217. .rect {
  218. background-color: #fff;
  219. padding: 30px 15px;
  220. border-radius: 5px;
  221. border: 1px solid #e8e8e8;
  222. }
  223. .rect-form {
  224. padding-bottom: 10px;
  225. }
  226. .rect-table {
  227. margin-top: 20px;
  228. }
  229. .demo-table-expand {
  230. font-size: 0;
  231. margin-left: 40px;
  232. }
  233. .demo-table-expand label {
  234. width: 90px;
  235. color: #99a9bf;
  236. }
  237. .demo-table-expand .el-form-item {
  238. margin-right: 0;
  239. margin-bottom: 0;
  240. width: 80%;
  241. }
  242. .el-table .height {
  243. background: rgba(254, 254, 254, 0.5);
  244. }
  245. /deep/ .el-table--mini td, .el-table--mini th {
  246. padding: 3px 0 !important;
  247. height: 20px !important;
  248. }
  249. /deep/ .el-checkbox__input.is-checked+.el-checkbox__label {
  250. color: rgb(24,144,255);
  251. background-color: rgb(24,144,255);
  252. border-color: rgb(24,144,255);
  253. }
  254. /deep/.el-table .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  255. background-color: rgb(24,144,255);
  256. border-color: rgb(24,144,255);
  257. }
  258. /deep/.el-table .el-checkbox__inner:hover {
  259. border-color: rgb(24,144,255);
  260. }
  261. /deep/.el-table .el-checkbox__input.is-focus .el-checkbox__inner {
  262. border-color: rgb(24,144,255);
  263. }
  264. /deep/.el-table #select .cell .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  265. background-color: rgb(24,144,255);
  266. border-color: rgb(24,144,255);
  267. }
  268. </style>