pbexit.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <template>
  2. <div class="mod-role">
  3. <el-container>
  4. <!-- form表单 -->
  5. <el-header>
  6. <div class="rect rect-form">
  7. <el-form :inline="true" :model="form" size="mini" ref="form">
  8. <el-form-item>
  9. <el-input v-model="form.eartag" placeholder="耳标" clearable></el-input>
  10. </el-form-item>
  11. <el-form-item style="width: 140px">
  12. <el-select placeholder="性别" v-model="form.sex">
  13. <el-option
  14. v-for="item in gender"
  15. :key="item.value"
  16. :label="item.label"
  17. :value="item.value">
  18. </el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item style="width: 140px">
  22. <el-select placeholder="品种" v-model="form.breed">
  23. <el-option
  24. v-for="item in breedList"
  25. :key="item.value"
  26. :label="item.label"
  27. :value="item.value">
  28. </el-option>
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item style="width: 140px">
  32. <el-select placeholder="健康状态" v-model="form.healthStatus">
  33. <el-option
  34. v-for="item in healthStatus"
  35. :key="item.value"
  36. :label="item.label"
  37. :value="item.value">
  38. </el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item style="width: 140px">
  42. <el-select placeholder="养殖状态" v-model="form.outFenceStatus">
  43. <el-option
  44. v-for="item in outFenceStatus"
  45. :key="item.value"
  46. :label="item.label"
  47. :value="item.value">
  48. </el-option>
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item style="width: 140px">
  52. <el-select
  53. placeholder="猪舍"
  54. v-model="form.pigstyId">
  55. <el-option
  56. v-for="item in pigstyList"
  57. :key="item.value"
  58. :label="item.label"
  59. :value="item.value">
  60. </el-option>
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item style="width: 140px">
  64. <el-select
  65. placeholder="单元"
  66. v-model="form.unitId"
  67. ref="unit"
  68. @focus="selectFocus('unit')">
  69. <el-option
  70. v-for="item in unitSelectedList"
  71. :key="item.value"
  72. :label="item.label"
  73. :value="item.value">
  74. </el-option>
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item style="width: 140px">
  78. <el-select
  79. placeholder="栏期"
  80. v-model="form.periodId"
  81. ref="period"
  82. @focus="selectFocus('period')">
  83. <el-option
  84. v-for="item in periodSelectedList"
  85. :key="item.value"
  86. :label="item.label"
  87. :value="item.value">
  88. </el-option>
  89. </el-select>
  90. </el-form-item>
  91. <el-form-item>
  92. <el-button @click="getDataList()" icon="el-icon-search">查 询</el-button>
  93. </el-form-item>
  94. <el-form-item>
  95. <el-button
  96. icon="el-icon-circle-close"
  97. @click="clearAll">清 空</el-button>
  98. </el-form-item>
  99. </el-form>
  100. </div>
  101. </el-header>
  102. <!-- role表格 -->
  103. <el-main>
  104. <div class="rect rect-table">
  105. <!-- 新增 删除按钮 -->
  106. <el-form inline size="mini">
  107. <!-- <el-form-item>
  108. <el-button
  109. icon="el-icon-plus"
  110. @click="addOrUpdateHandle()">
  111. 新 增
  112. </el-button>
  113. </el-form-item> -->
  114. <el-form-item>
  115. <el-button
  116. icon="el-icon-d-arrow-right"
  117. type="danger"
  118. @click="deleteHandle()"
  119. :disabled="dataListSelections.length <= 0">
  120. 出 栏
  121. </el-button>
  122. </el-form-item>
  123. <!-- <el-form-item>
  124. <el-button
  125. icon="el-icon-edit"
  126. type="danger"
  127. @click="addOrUpdateHandle()"
  128. :disabled="dataListSelections.length <= 0">
  129. 批量修改
  130. </el-button>
  131. </el-form-item> -->
  132. </el-form>
  133. <el-table
  134. :data="dataList"
  135. border
  136. stripe
  137. v-loading="dataListLoading"
  138. @selection-change="selectionChangeHandle"
  139. style="width: 100%;"
  140. size="mini"
  141. height="540"
  142. :header-cell-style="{background:'rgb(245,245,245)',color:'#000',height: '45px',fontSize: '13px',fontWeight: 'normal',borderBottom: '1px solid #ccc'}"
  143. :cell-style="{color: '#888',fontSize: '13px'}">
  144. <el-table-column
  145. type="selection"
  146. header-align="center"
  147. align="center"
  148. width="50">
  149. </el-table-column>
  150. <el-table-column
  151. prop="id"
  152. header-align="center"
  153. align="center"
  154. label="id"
  155. width="80">
  156. </el-table-column>
  157. <el-table-column
  158. prop="eartag"
  159. header-align="center"
  160. align="center"
  161. label="耳标">
  162. </el-table-column>
  163. <el-table-column
  164. prop="sex"
  165. header-align="center"
  166. align="center"
  167. label="性别"
  168. width="80">
  169. </el-table-column>
  170. <el-table-column
  171. prop="birthday"
  172. header-align="center"
  173. align="center"
  174. label="出生日期">
  175. </el-table-column>
  176. <el-table-column
  177. header-align="center"
  178. align="center"
  179. label="健康状态"
  180. width="100">
  181. <template slot-scope="scope">
  182. <span>{{scope.row.healthStatus? '健康': '不健康'}}</span>
  183. </template>
  184. </el-table-column>
  185. <el-table-column
  186. header-align="center"
  187. align="center"
  188. label="养殖状态"
  189. width="100">
  190. <template slot-scope="scope">
  191. <span>{{scope.row.outFenceStatus? '出栏': '育肥'}}</span>
  192. </template>
  193. </el-table-column>
  194. <el-table-column
  195. prop="breed"
  196. header-align="center"
  197. align="center"
  198. label="品种"
  199. width="100">
  200. </el-table-column>
  201. <el-table-column
  202. prop="pigstyName"
  203. header-align="center"
  204. align="center"
  205. label="猪舍">
  206. </el-table-column>
  207. <el-table-column
  208. prop="unitName"
  209. header-align="center"
  210. align="center"
  211. label="单元">
  212. </el-table-column>
  213. <el-table-column
  214. prop="periodName"
  215. header-align="center"
  216. align="center"
  217. label="栏期">
  218. </el-table-column>
  219. <el-table-column
  220. header-align="center"
  221. align="center"
  222. label="操作">
  223. <template slot-scope="scope">
  224. <!-- <el-button
  225. type="text"
  226. size="medium"
  227. style="color: rgb(24,144,255)">
  228. 查看
  229. </el-button> -->
  230. <el-button
  231. type="text"
  232. size="medium"
  233. @click="deleteHandle(scope.row)"
  234. style="color: rgb(24,144,255)">
  235. 出栏
  236. </el-button>
  237. </template>
  238. </el-table-column>
  239. </el-table>
  240. <el-pagination
  241. @size-change="sizeChangeHandle"
  242. @current-change="currentChangeHandle"
  243. :current-page="pageIndex"
  244. :page-sizes="[10, 20, 50, 100]"
  245. :page-size="pageSize"
  246. :total="totalPage"
  247. layout="total, sizes, prev, pager, next, jumper">
  248. </el-pagination>
  249. <!-- 弹窗, 新增 / 修改 -->
  250. <!-- <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update> -->
  251. </div>
  252. </el-main>
  253. </el-container>
  254. </div>
  255. </template>
  256. <script>
  257. // import AddOrUpdate from './pbentry-add-or-update'
  258. export default {
  259. data () {
  260. return {
  261. form: {
  262. eartag: '',
  263. sex: '',
  264. breed: '',
  265. healthStatus: '',
  266. outFenceStatus: '',
  267. periodId: '',
  268. pigstyId: '',
  269. unitId: ''
  270. },
  271. dataList: [],
  272. pageIndex: 1,
  273. pageSize: 10,
  274. totalPage: 0,
  275. dataListLoading: false,
  276. dataListSelections: [],
  277. addOrUpdateVisible: false,
  278. farmId: undefined,
  279. gender: [
  280. {
  281. value: '公',
  282. label: '公'
  283. },
  284. {
  285. value: '母',
  286. label: '母'
  287. }
  288. ],
  289. breedList: [],
  290. healthStatus: [
  291. {
  292. value: 1,
  293. label: '健康'
  294. },
  295. {
  296. value: 0,
  297. label: '不健康'
  298. }
  299. ],
  300. outFenceStatus: [
  301. {
  302. value: 0,
  303. label: '育肥'
  304. },
  305. {
  306. value: 1,
  307. label: '出栏'
  308. }
  309. ],
  310. periodList: [], // 所有栏期
  311. periodSelectedList: [], // 根据栋舍限制的栏期
  312. pigstyList: [], // 所有栋舍
  313. unitList: [], // 所有单元
  314. unitSelectedList: [], // 根据栋舍限制的单元
  315. labelPosition: 'right'
  316. }
  317. },
  318. // components: {
  319. // AddOrUpdate
  320. // },
  321. activated () {
  322. this.getDataList()
  323. },
  324. methods: {
  325. // 获取数据列表
  326. getDataList () {
  327. this.dataListLoading = true
  328. // 如果是新增
  329. // if (val === 'add') {
  330. // this.pageIndex = (this.dataList.length % this.pageSize === 0? this.totalPage + 1: this.totalPage)
  331. // console.log(this.pageIndex);
  332. // } else if (val === 'del') {
  333. // this.pageIndex = Math.ceil((this.dataList.length - this.delLength) / this.pageSize)
  334. // }
  335. // 对 新增or删除 操作,当前页为最后一页
  336. // if (val) {
  337. // let valArr = val.split('-')
  338. // let total = 0
  339. // if (valArr[0] === 'add') {
  340. // total = this.totalPage + parseInt(valArr[1])
  341. // } else if (valArr[0] === 'del') {
  342. // total = this.totalPage - parseInt(valArr[1])
  343. // }
  344. // this.pageIndex = Math.ceil(total / this.pageSize)
  345. // }
  346. this.$http({
  347. url: this.$http.adornUrl('/management/yearpigbase/fattenList'),
  348. method: 'get',
  349. params: this.$http.adornParams({
  350. 'page': this.pageIndex,
  351. 'limit': this.pageSize,
  352. 'eartag': this.form.eartag || undefined,
  353. 'sex': this.form.sex || undefined,
  354. 'breed': this.form.breed || undefined,
  355. 'healthStatus': this.form.healthStatus || (this.form.healthStatus === 0?this.form.healthStatus: undefined),
  356. 'outFenceStatus': this.form.outFenceStatus || (this.form.outFenceStatus === 0?this.form.outFenceStatus: undefined),
  357. 'periodId': this.form.periodId || undefined,
  358. 'pigstyId': this.form.pigstyId || undefined,
  359. 'unitId': this.form.unitId || undefined
  360. })
  361. }).then(async({data}) => {
  362. // 猪舍List
  363. this.pigstyList = []
  364. let pigstyList = []
  365. let pigstyR = await this.$http({
  366. url: this.$http.adornUrl("/management/pigsty/findAll"),
  367. method: "get",
  368. params: this.$http.adornParams({})
  369. })
  370. pigstyR.data.all && (pigstyList = pigstyR.data.all)
  371. pigstyList.forEach(pigsty => {
  372. let item = {
  373. value: pigsty.id,
  374. label: pigsty.number
  375. }
  376. this.pigstyList.push(item)
  377. })
  378. // 单元List
  379. this.unitList = []
  380. let unitList = []
  381. let unitR = await this.$http({
  382. url: this.$http.adornUrl("/management/unit/findAll"),
  383. method: "get",
  384. params: this.$http.adornParams({})
  385. })
  386. unitR.data.all && (unitList = unitR.data.all)
  387. unitList.forEach(unit => {
  388. let item = {
  389. value: unit.id,
  390. label: unit.number,
  391. pigstyId: unit.pigstyId
  392. }
  393. this.unitList.push(item)
  394. })
  395. this.unitSelectedList = this.unitList
  396. // 栏期List
  397. this.periodList = []
  398. let periodList = []
  399. let periodR = await this.$http({
  400. url: this.$http.adornUrl("/management/period/findAll"),
  401. method: "get",
  402. params: this.$http.adornParams({})
  403. })
  404. periodR.data.all && (periodList = periodR.data.all)
  405. periodList.forEach(period => {
  406. let item = {
  407. value: period.id,
  408. label: period.number,
  409. pigstyId: period.pigstyId
  410. }
  411. this.periodList.push(item)
  412. })
  413. this.periodSelectedList = this.form.pigstyId? this.periodList.filter(item => item.pigstyId === this.form.pigstyId): this.periodList
  414. this.unitSelectedList = this.form.pigstyId? this.unitList.filter(item => item.pigstyId === this.form.pigstyId): this.unitList
  415. // 品种List
  416. this.breedList = []
  417. let breedList = []
  418. let breedR = await this.$http({
  419. url: this.$http.adornUrl("/management/basebloodline/findAll"),
  420. method: "get",
  421. params: this.$http.adornParams({})
  422. })
  423. breedR.data.all && (breedList = breedR.data.all)
  424. breedList.forEach(breed => {
  425. let item = {
  426. value: breed.name,
  427. label: breed.name
  428. }
  429. this.breedList.push(item)
  430. })
  431. // 获取猪只List
  432. if (data && data.code === 0) {
  433. this.dataList = data.page.list
  434. this.totalPage = data.page.totalCount
  435. } else {
  436. this.dataList = []
  437. this.totalPage = 0
  438. this.$message.error(data.msg)
  439. }
  440. this.dataListLoading = false
  441. })
  442. },
  443. // // 根据栋舍选择限制单元和栏期
  444. // pigstyChange (val) {
  445. // this.unitSelectedList = this.unitList.filter(item => item.pigstyId === val)
  446. // this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
  447. // },
  448. // // 需要先选择猪舍,才能选择单元或栏期
  449. // ifPigsty (val) {
  450. // if (!this.form.pigstyId) {
  451. // this.$message.error('请先选择猪舍')
  452. // this.form[val] = ''
  453. // }
  454. // },
  455. // 点击 单元or栏期的选择框
  456. selectFocus (val) {
  457. if (!this.form.pigstyId) {
  458. this.$message.error('请先选择猪舍')
  459. this.form[val + 'Id'] = ''
  460. setTimeout(() => {
  461. this.$refs[val].blur()
  462. }, 10)
  463. }
  464. },
  465. // form表单清空,单元SelectedList 和 栏期SelectedList重置
  466. clearAll () {
  467. for (let i in this.form) {
  468. this.form[i] = ''
  469. }
  470. this.unitSelectedList = this.unitList
  471. this.periodSelectedList = this.periodList
  472. },
  473. // 每页数
  474. sizeChangeHandle (val) {
  475. this.pageSize = val
  476. this.pageIndex = 1
  477. this.getDataList()
  478. },
  479. // 当前页
  480. currentChangeHandle (val) {
  481. this.pageIndex = val
  482. this.getDataList()
  483. },
  484. // 多选
  485. selectionChangeHandle (val) {
  486. this.dataListSelections = val
  487. },
  488. // // 新增 / 修改
  489. // addOrUpdateHandle (id) {
  490. // this.addOrUpdateVisible = true
  491. // var ids = id ? [id] : this.dataListSelections.map(item => {
  492. // return {
  493. // id: item.id,
  494. // eartag: item.eartag
  495. // }
  496. // })
  497. // this.$nextTick(() => {
  498. // this.$refs.addOrUpdate.init(ids)
  499. // })
  500. // },
  501. // 出栏
  502. deleteHandle (pig) {
  503. var ids = pig ? [pig.id] : this.dataListSelections.map(item => {
  504. return item.id
  505. })
  506. var eartags = pig ? [pig.eartag] : this.dataListSelections.map(item => {
  507. return item.eartag
  508. })
  509. this.$confirm(`确定${pig ? '出栏' : '批量出栏'}耳标号${eartags.join(',')}的猪只?`, '提示', {
  510. confirmButtonText: '确定',
  511. cancelButtonText: '取消',
  512. type: 'warning'
  513. }).then(() => {
  514. this.$http({
  515. url: this.$http.adornUrl('/management/yearpigbase/such'),
  516. method: 'post',
  517. data: this.$http.adornData(ids, false)
  518. }).then(({data}) => {
  519. if (data && data.code === 0) {
  520. this.$message({
  521. message: '操作成功',
  522. type: 'success',
  523. duration: 1500,
  524. // onClose: () => {
  525. // this.getDataList()
  526. // }
  527. })
  528. this.getDataList()
  529. } else {
  530. this.$message.error(data.msg)
  531. }
  532. })
  533. }).catch(() => {})
  534. }
  535. },
  536. watch: {
  537. 'form.pigstyId': {
  538. handler(newValue, oldValue) {
  539. if (oldValue) {
  540. this.form.unitId = ''
  541. this.form.periodId = ''
  542. }
  543. this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
  544. this.periodSelectedList = this.periodList.filter(item => item.pigstyId === newValue)
  545. }
  546. }
  547. }
  548. }
  549. </script>
  550. <style scoped>
  551. .rect {
  552. background-color: #fff;
  553. padding: 30px 15px;
  554. border-radius: 5px;
  555. border: 1px solid #e8e8e8;
  556. }
  557. .rect-form {
  558. padding-bottom: 10px;
  559. }
  560. .rect-table {
  561. margin-top: 20px;
  562. }
  563. .demo-table-expand {
  564. font-size: 0;
  565. margin-left: 40px;
  566. }
  567. .demo-table-expand label {
  568. width: 90px;
  569. color: #99a9bf;
  570. }
  571. .demo-table-expand .el-form-item {
  572. margin-right: 0;
  573. margin-bottom: 0;
  574. width: 80%;
  575. }
  576. .el-table .height {
  577. background: rgba(254, 254, 254, 0.5);
  578. }
  579. /deep/ .el-table--mini td, .el-table--mini th {
  580. padding: 3px 0 !important;
  581. height: 20px !important;
  582. }
  583. /deep/ .el-checkbox__input.is-checked+.el-checkbox__label {
  584. color: rgb(24,144,255);
  585. background-color: rgb(24,144,255);
  586. border-color: rgb(24,144,255);
  587. }
  588. /deep/.el-table .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  589. background-color: rgb(24,144,255);
  590. border-color: rgb(24,144,255);
  591. }
  592. /deep/.el-table .el-checkbox__inner:hover {
  593. border-color: rgb(24,144,255);
  594. }
  595. /deep/.el-table .el-checkbox__input.is-focus .el-checkbox__inner {
  596. border-color: rgb(24,144,255);
  597. }
  598. /deep/.el-table #select .cell .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  599. background-color: rgb(24,144,255);
  600. border-color: rgb(24,144,255);
  601. }
  602. </style>