5bc65228756c1c68463db1b2253ad66aace55ab2.svn-base 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button class="success" style="float: left;" @click="handleNutritional">营养评估</el-button>
  5. <el-button class="import" style="float: right;">导入</el-button>
  6. <el-dropdown style="float: right;margin-right: 10px;" @click="handleExport">
  7. <el-button class="export">导出</el-button>
  8. <el-dropdown-menu slot="dropdown">
  9. <el-dropdown-item @click.native="handleExportTemp">导出模板</el-dropdown-item>
  10. <el-dropdown-item @click.native="handleExport">导出数据</el-dropdown-item>
  11. </el-dropdown-menu>
  12. </el-dropdown>
  13. <el-button class="export" style="float: right;margin-right: 10px;" @click="handleHistoryRecords">历史记录</el-button>
  14. </div>
  15. <div class="search" />
  16. <div class="table">
  17. <el-table
  18. :key="table.tableKey"
  19. v-loading="table.listLoading"
  20. element-loading-text="给我一点时间"
  21. :data="table.list"
  22. border
  23. fit
  24. highlight-current-row
  25. style="width: 100%;"
  26. :row-style="rowStyle"
  27. :cell-style="cellStyle"
  28. class="elTable table-fixed"
  29. @header-click="headerClick"
  30. @selection-change="handleSelect"
  31. >
  32. <el-table-column type="selection" width="50" />
  33. <el-table-column label="序号" align="center" type="index" width="50px">
  34. <template slot-scope="scope">
  35. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="栏舍名称" min-width="130px" align="center">
  39. <template slot-scope="scope">
  40. <span>{{ scope.row.brandName }}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="软件牛头数" min-width="130px" align="center">
  44. <template slot-scope="scope">
  45. <span>{{ scope.row.brandName }}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="实际牛头数" min-width="130px" align="center">
  49. <template slot-scope="scope">
  50. <span v-if="scope.row.NoEdit">{{ scope.row.brandName }}</span>
  51. <el-input v-if="scope.row.Edit" v-model="scope.row.brandName" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="系数(%)" min-width="130px" align="center">
  55. <template slot-scope="scope">
  56. <span v-if="scope.row.NoEdit">{{ scope.row.brandName }}</span>
  57. <el-input v-if="scope.row.Edit" v-model="scope.row.brandName" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="配方模板" min-width="110px" align="center">
  61. <template slot-scope="scope">
  62. <span v-if="scope.row.NoEdit">{{ scope.row.brandName }}</span>
  63. <el-select filterable v-if="scope.row.Edit" v-model="scope.row.brandName" placeholder="配方模板" class="filter-item" style="width:80%;padding:10px 0;">
  64. <el-option v-for="item in recipeTemplateList" :key="item.id" :label="item.name" :value="item.name" />
  65. </el-select>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="早班比例(%)" min-width="130px" align="center">
  69. <template slot-scope="scope">
  70. <span v-if="scope.row.NoEdit">{{ scope.row.brandName }}</span>
  71. <el-input v-if="scope.row.Edit" v-model="scope.row.brandName" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="早班重量" min-width="130px" align="center" :render-header="renderHeader">
  75. <template slot-scope="scope">
  76. <span v-if="scope.row.NoEdit">{{ scope.row.eqName }}</span>
  77. <el-input v-if="scope.row.Edit" v-model="scope.row.eqName" :disabled="scope.row.isMorningWeight" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="中班比例(%)" min-width="130px" align="center">
  81. <template slot-scope="scope">
  82. <span v-if="scope.row.NoEdit">{{ scope.row.brandName }}</span>
  83. <el-input v-if="scope.row.Edit" v-model="scope.row.brandName" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="中班重量" min-width="130px" align="center" :render-header="renderHeader">
  87. <template slot-scope="scope">
  88. <span v-if="scope.row.NoEdit">{{ scope.row.eqName }}</span>
  89. <el-input v-if="scope.row.Edit" v-model="scope.row.eqName" :disabled="scope.row.isMiddleWeight" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="晚班比例(%)" min-width="130px" align="center">
  93. <template slot-scope="scope">
  94. <span v-if="scope.row.NoEdit">{{ scope.row.brandName }}</span>
  95. <el-input v-if="scope.row.Edit" v-model="scope.row.brandName" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="晚班重量" min-width="130px" align="center" :render-header="renderHeader">
  99. <template slot-scope="scope">
  100. <span v-if="scope.row.NoEdit">{{ scope.row.eqName }}</span>
  101. <el-input v-if="scope.row.Edit" v-model="scope.row.eqName" :disabled="scope.row.isNightWeight" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="总比例(%)" min-width="130px" align="center">
  105. <template slot-scope="scope">
  106. <span>{{ scope.row.brandName }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="投喂量" min-width="130px" align="center">
  110. <template slot-scope="scope">
  111. <span>{{ scope.row.brandName }}</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="配方重量" min-width="130px" align="center">
  115. <template slot-scope="scope">
  116. <span>{{ scope.row.brandName }}</span>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="补料重量" min-width="130px" align="center">
  120. <template slot-scope="scope">
  121. <span>{{ scope.row.brandName }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  125. <template slot-scope="{row}">
  126. <!-- 编辑 -->
  127. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  128. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  129. <!-- 编辑保存 -->
  130. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  131. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  132. </template>
  133. </el-table-column>
  134. </el-table>
  135. <pagination v-show="table.total>0" :total="table.total" :page.sync="getdataListParm.offset" :limit.sync="getdataListParm.pagecount" @pagination="getList" />
  136. </div>
  137. <!-- 营养评估 -->
  138. <el-dialog :title="textMap[nutritional.dialogStatus]" :destroy-on-close="true" :visible.sync="nutritional.dialogFormVisible" :close-on-click-modal="false" width="90%">
  139. <div class="app-nutritional">
  140. <h4 style="position: absolute;top:-5px;left:140px;font:18px/24px '' ;color:#303133;">栏舍:</h4>
  141. <el-form ref="nutritional.temp" :rules="nutritional.rules" :model="nutritional.temp" label-position="right" label-width="95px" style="width: 100%;margin-bottom:30px">
  142. <el-row>
  143. <el-col :span="4">
  144. <el-form-item label="类别" prop="eqClassName">
  145. <el-select filterable v-model="nutritional.temp.eqClassName" placeholder="" class="filter-item" style="width:100%;">
  146. <el-option v-for="item in livestockTypeList" :key="item.id" :label="item.name" :value="item.name" />
  147. </el-select>
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="4">
  151. <el-form-item label="月龄" prop="eqClassName">
  152. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="4">
  156. <el-form-item label="体重(kg)" prop="eqClassName">
  157. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="4">
  161. <el-form-item label="日增重(kg)" prop="eqClassName">
  162. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="4">
  166. <el-form-item label="胎次(次)" prop="eqClassName">
  167. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  168. </el-form-item>
  169. </el-col>
  170. <el-col :span="4">
  171. <el-form-item label="泌乳天数(天)" prop="eqClassName">
  172. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  173. </el-form-item>
  174. </el-col>
  175. </el-row>
  176. <el-row>
  177. <el-col :span="4">
  178. <el-form-item label="怀孕天数(天)" prop="eqClassName">
  179. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  180. </el-form-item>
  181. </el-col>
  182. <el-col :span="4">
  183. <el-form-item label="产奶量(kg)" prop="eqClassName">
  184. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  185. </el-form-item>
  186. </el-col>
  187. <el-col :span="4">
  188. <el-form-item label="乳脂率(%)" prop="eqClassName">
  189. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  190. </el-form-item>
  191. </el-col>
  192. <el-col :span="4">
  193. <el-form-item label="乳蛋白率(%)" prop="eqClassName">
  194. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  195. </el-form-item>
  196. </el-col>
  197. <el-col :span="4">
  198. <el-form-item label="乳糖率(%)" prop="eqClassName">
  199. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  200. </el-form-item>
  201. </el-col>
  202. <el-col :span="4">
  203. <el-form-item label="温度(℃)" prop="eqClassName">
  204. <el-input ref="eqClassName" v-model="nutritional.temp.eqClassName" class="filter-item" placeholder="" style="width:100%;" />
  205. </el-form-item>
  206. </el-col>
  207. </el-row>
  208. </el-form>
  209. <div style="position: relative;height: 50px;">
  210. <el-button class="success" :disabled="isokDisable" style="position: absolute;left: 0;right: 0;margin:0 auto;" @click="assessmentData()">评估</el-button>
  211. </div>
  212. <div class="table">
  213. <el-table
  214. :key="nutritional.tableKey"
  215. v-loading="nutritional.listLoading"
  216. element-loading-text="给我一点时间"
  217. :data="nutritional.list"
  218. border
  219. fit
  220. highlight-current-row
  221. style="width: 100%;margin-bottom:60px;"
  222. :row-style="rowStyle"
  223. :cell-style="cellStyle"
  224. class="elTable table-fixed"
  225. >
  226. <el-table-column type="selection" width="50" />
  227. <el-table-column label="序号" align="center" type="index" width="50px">
  228. <template slot-scope="scope">
  229. <span>{{ scope.$index + (nutritional.pageNum-1) * nutritional.pageSize + 1 }}</span>
  230. </template>
  231. </el-table-column>
  232. <el-table-column label="指标" min-width="130px" align="center">
  233. <template slot-scope="scope">
  234. <span>{{ scope.row.brandName }}</span>
  235. </template>
  236. </el-table-column>
  237. <el-table-column label="奶牛需要" min-width="130px" align="center">
  238. <template slot-scope="scope">
  239. <span>{{ scope.row.brandName }}</span>
  240. </template>
  241. </el-table-column>
  242. <el-table-column label="饲料提供" min-width="130px" align="center">
  243. <template slot-scope="scope">
  244. <span>{{ scope.row.brandName }}</span>
  245. </template>
  246. </el-table-column>
  247. <el-table-column label="实际执行" min-width="130px" align="center">
  248. <template slot-scope="scope">
  249. <span>{{ scope.row.brandName }}</span>
  250. </template>
  251. </el-table-column>
  252. <el-table-column label="相差" min-width="130px" align="center">
  253. <template slot-scope="scope">
  254. <span>{{ scope.row.brandName }}</span>
  255. </template>
  256. </el-table-column>
  257. <el-table-column label="粗料提供" min-width="130px" align="center">
  258. <template slot-scope="scope">
  259. <span>{{ scope.row.brandName }}</span>
  260. </template>
  261. </el-table-column>
  262. <el-table-column label="精料提供" min-width="130px" align="center">
  263. <template slot-scope="scope">
  264. <span>{{ scope.row.brandName }}</span>
  265. </template>
  266. </el-table-column>
  267. </el-table>
  268. </div>
  269. <div slot="footer" class="dialog-footer">
  270. <el-button class="cancel" @click="nutritional.dialogFormVisible = false; ">关闭</el-button>
  271. </div>
  272. </div>
  273. </el-dialog>
  274. </div>
  275. </template>
  276. <script>
  277. import { GetDataByName } from '@/api/common'
  278. import Pagination from '@/components/Pagination'
  279. export default {
  280. name: 'DhedFormula',
  281. components: { Pagination },
  282. data() {
  283. return {
  284. recipeTemplateList: [{ id: 0, name: '泌乳牛高产' }, { id: 1, name: '高产日粮' }], // 配方模板
  285. livestockTypeList: [{ id: 0, name: '高产' }, { id: 1, name: '低产' }, { id: 2, name: '中产' }, { id: 3, name: '青年后备' }, { id: 4, name: '围产' }], // 类别
  286. getdataListParm: {
  287. name: 'getAssetList',
  288. page: 1,
  289. offset: 1,
  290. pagecount: 10,
  291. returntype: 'Map',
  292. parammaps: {
  293. enable: ''
  294. }
  295. },
  296. table: {
  297. tableKey: 0,
  298. list: [],
  299. total: 0,
  300. listLoading: true
  301. },
  302. selectList: [],
  303. nutritional: {
  304. dialogFormVisible: false,
  305. dialogStatus: '',
  306. temp: {},
  307. rules: {},
  308. tableKey: 0,
  309. list: [],
  310. total: 0,
  311. listLoading: true,
  312. getdataListParm: {
  313. name: 'getAssetList',
  314. page: 1,
  315. offset: 1,
  316. pagecount: 10,
  317. returntype: 'Map',
  318. parammaps: {
  319. enable: ''
  320. }
  321. }
  322. },
  323. textMap: {
  324. Nutritional: '营养评估'
  325. },
  326. isokDisable: false,
  327. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  328. cellStyle: { padding: 0 + 'px' }
  329. }
  330. },
  331. created() {
  332. this.getList()
  333. },
  334. methods: {
  335. getList() {
  336. this.table.listLoading = true
  337. GetDataByName(this.getdataListParm).then(response => {
  338. console.log('table数据', response.data.list)
  339. if (response.data.list !== null) {
  340. for (let i = 0; i < response.data.list.length; i++) {
  341. this.$set(response.data.list[i], 'Edit', false) // 编辑
  342. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  343. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  344. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  345. }
  346. this.table.list = response.data.list
  347. this.table.pageNum = response.data.pageNum
  348. this.table.pageSize = response.data.pageSize
  349. this.table.total = response.data.total
  350. } else {
  351. this.table.list = []
  352. }
  353. setTimeout(() => {
  354. this.table.listLoading = false
  355. }, 100)
  356. })
  357. },
  358. renderHeader(h, { column, $index }) { // h即为cerateElement的简写,具体可看vue官方文档
  359. console.log(column)
  360. return h(
  361. 'div',
  362. [
  363. h('span', column.label),
  364. h('i', { class: 'el-icon-unlock', ref: 'el-icon-unlock', style: 'margin-left:5px;' })
  365. ],
  366. )
  367. },
  368. headerClick(column, event) {
  369. console.log(column, event)
  370. if (column.label == '早班重量') {
  371. for (let i = 0; i < this.table.list.length; i++) {
  372. if (this.table.list[i].Edit == true) {
  373. if (event.target.outerHTML == '<i class="el-icon-unlock" style="margin-left: 5px;"></i>') {
  374. event.target.className = 'el-icon-lock'
  375. this.$set(this.table.list[i], 'isMorningWeight', true) // 锁住不可编辑
  376. } else if (event.target.outerHTML == '<i class="el-icon-lock" style="margin-left: 5px;"></i>') {
  377. event.target.className = 'el-icon-unlock'
  378. this.$set(this.table.list[i], 'isMorningWeight', false) // 解锁可编辑
  379. }
  380. }
  381. }
  382. } else if (column.label == '中班重量') {
  383. for (let i = 0; i < this.table.list.length; i++) {
  384. if (this.table.list[i].Edit == true) {
  385. if (event.target.outerHTML == '<i class="el-icon-unlock" style="margin-left: 5px;"></i>') {
  386. event.target.className = 'el-icon-lock'
  387. this.$set(this.table.list[i], 'isMiddleWeight', true) // 锁住不可编辑
  388. } else if (event.target.outerHTML == '<i class="el-icon-lock" style="margin-left: 5px;"></i>') {
  389. event.target.className = 'el-icon-unlock'
  390. this.$set(this.table.list[i], 'isMiddleWeight', false) // 解锁可编辑
  391. }
  392. }
  393. }
  394. } else if (column.label == '晚班重量') {
  395. for (let i = 0; i < this.table.list.length; i++) {
  396. if (this.table.list[i].Edit == true) {
  397. if (event.target.outerHTML == '<i class="el-icon-unlock" style="margin-left: 5px;"></i>') {
  398. event.target.className = 'el-icon-lock'
  399. this.$set(this.table.list[i], 'isNightWeight', true) // 锁住不可编辑
  400. } else if (event.target.outerHTML == '<i class="el-icon-lock" style="margin-left: 5px;"></i>') {
  401. event.target.className = 'el-icon-unlock'
  402. this.$set(this.table.list[i], 'isNightWeight', false) // 解锁可编辑
  403. }
  404. }
  405. }
  406. }
  407. },
  408. handleUpdate(row) {
  409. for (let i = 0; i < this.table.list.length; i++) {
  410. if (this.table.list[i].Edit == true) {
  411. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  412. return false
  413. }
  414. }
  415. // 编辑true,不可编辑false
  416. row.Edit = true
  417. row.NoEdit = false
  418. // 编辑false,编辑保存true
  419. row.isUpdate = false
  420. row.isUpdateSave = true
  421. },
  422. updateData(row) {
  423. console.log('点击了编辑保存', row)
  424. },
  425. updateCancel(row) {
  426. console.log('点击了编辑取消')
  427. // 编辑false,不可编辑true
  428. row.Edit = false
  429. row.NoEdit = true
  430. // 编辑true,编辑保存false
  431. row.isUpdate = true
  432. row.isUpdateSave = false
  433. },
  434. handleRowDelete(row) {
  435. console.log('点击了行内删除')
  436. },
  437. handleSelect(val) {
  438. console.log('勾选数据', val)
  439. this.selectList = val
  440. },
  441. // 营养评估
  442. handleNutritional() {
  443. console.log('点击了营养评估')
  444. if (this.selectList.length !== 1) {
  445. this.$message({ type: 'error', message: '请选择一条栏舍信息进行营养评估', duration: 2000 })
  446. return false
  447. } else {
  448. this.temp = this.selectList
  449. this.nutritional.dialogStatus = 'Nutritional'
  450. this.nutritional.dialogFormVisible = true
  451. this.getList2()
  452. }
  453. },
  454. assessmentData() {
  455. console.log('评估保存')
  456. this.getList2()
  457. },
  458. getList2() {
  459. this.nutritional.listLoading = true
  460. GetDataByName(this.nutritional.getdataListParm).then(response => {
  461. console.log('table数据', response.data.list)
  462. if (response.data.list !== null) {
  463. this.nutritional.list = response.data.list
  464. this.nutritional.pageNum = response.data.pageNum
  465. this.nutritional.pageSize = response.data.pageSize
  466. this.nutritional.total = response.data.total
  467. } else {
  468. this.nutritional.list = []
  469. }
  470. setTimeout(() => {
  471. this.nutritional.listLoading = false
  472. }, 100)
  473. })
  474. },
  475. // 历史记录
  476. handleHistoryRecords() {
  477. console.log('点击了历史记录')
  478. },
  479. // 导出模板
  480. handleExportTemp() {
  481. console.log('点击了导出模板')
  482. },
  483. // 导出
  484. handleExport() {
  485. console.log('点击了导出数据')
  486. },
  487. // 导入
  488. handleImport() {
  489. console.log('点击了导入')
  490. }
  491. }
  492. }
  493. </script>
  494. <style lang="scss" scoped>
  495. .search{clear: both;}
  496. .table{margin-top:10px;}
  497. </style>