3e1ae7f8df680b46584df7195540a42f6a62d85a.svn-base 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button v-if="isRoleEdit" class="success" style="float: left;margin-right:10px;" @click="handleCreate">新增</el-button>
  5. <el-button v-if="isRoleEdit" class="danger" style="float: left;margin-right:10px;" @click="handleDelete">删除</el-button>
  6. <el-button v-if="isRoleEdit" class="warning" style="float: left;margin-right:10px;" @click="handleCopy">复制</el-button>
  7. <el-upload v-if="isRoleEdit" style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  8. <el-button class="import" style="float: right;">导入</el-button>
  9. </el-upload>
  10. <el-dropdown style="float: right;margin-right: 10px;">
  11. <el-button class="export">导出</el-button>
  12. <el-dropdown-menu slot="dropdown">
  13. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  14. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  15. </el-dropdown-menu>
  16. </el-dropdown>
  17. </div>
  18. <div class="search">
  19. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  20. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  21. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  22. <el-select v-model="table.getdataListParm.parammaps.barid" filterable placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  23. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  24. </el-select>
  25. <el-select v-model="table.getdataListParm.parammaps.cowclass" filterable placeholder="牲畜类别" class="filter-item" style="width: 120px;" clearable>
  26. <el-option v-for="item in livestockList" :key="item.id" :label="item.mixname" :value="item.classname" />
  27. </el-select>
  28. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  29. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  30. </div>
  31. <div class="table">
  32. <el-table
  33. :key="table.tableKey"
  34. v-loading="table.listLoading"
  35. element-loading-text="给我一点时间"
  36. :data="table.list"
  37. border
  38. fit
  39. highlight-current-row
  40. style="width: 100%;"
  41. :row-style="rowStyle"
  42. :cell-style="cellStyle"
  43. class="elTable table-fixed"
  44. @selection-change="handleSelectionChange"
  45. >
  46. <el-table-column type="selection" align="center" width="50" />
  47. <el-table-column label="序号" align="center" type="index" width="50px">
  48. <template slot-scope="scope">
  49. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="栏舍名称" min-width="150px" align="center">
  53. <template slot-scope="scope">
  54. <span>{{ scope.row.barname }}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="牲畜类别" min-width="150px" align="center">
  58. <template slot-scope="scope">
  59. <span>{{ scope.row.cowclass }}</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="牛头数" min-width="90px" align="center">
  63. <template slot-scope="scope">
  64. <span>{{ scope.row.cowsum }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="月龄" min-width="90px" align="center">
  68. <template slot-scope="scope">
  69. <span>{{ scope.row.avgmonthage }}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="体重(kg)" min-width="90px" align="center">
  73. <template slot-scope="scope">
  74. <span>{{ scope.row.bw }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="日增重(kg)" min-width="90px" align="center">
  78. <template slot-scope="scope">
  79. <span>{{ scope.row.dayw }}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="胎次" min-width="80px" align="center">
  83. <template slot-scope="scope">
  84. <span>{{ scope.row.fetal }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="平均泌乳天数" min-width="110px" align="center">
  88. <template slot-scope="scope">
  89. <span>{{ scope.row.avgdim }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="怀孕天数" min-width="90px" align="center">
  93. <template slot-scope="scope">
  94. <span>{{ scope.row.dayspre }}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="产奶量(kg/头)" min-width="110px" align="center">
  98. <template slot-scope="scope">
  99. <span>{{ scope.row.product }}</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="乳脂率(%)" min-width="90px" align="center">
  103. <template slot-scope="scope">
  104. <span>{{ scope.row.fat }}</span>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="乳蛋白率(%)" min-width="100px" align="center">
  108. <template slot-scope="scope">
  109. <span>{{ scope.row.pro }}</span>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="乳糖率(%)" min-width="90px" align="center">
  113. <template slot-scope="scope">
  114. <span>{{ scope.row.lactose }}</span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="温度(℃)" min-width="110px" align="center">
  118. <template slot-scope="scope">
  119. <span>{{ scope.row.tem }}</span>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="记录人" min-width="90px" align="center">
  123. <template slot-scope="scope">
  124. <span>{{ scope.row.emp }}</span>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="生效时间" min-width="110px" align="center">
  128. <template slot-scope="scope">
  129. <span>{{ scope.row.productdate }}</span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  133. <template slot-scope="{row}">
  134. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  135. <el-button v-if="isRoleEdit" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  140. </div>
  141. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  142. <div class="app-add">
  143. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="135px" style="width: 100%;margin:0 auto 50px">
  144. <el-row>
  145. <el-col :span="6">
  146. <el-form-item label="生效日期:" prop="productdate">
  147. <el-date-picker v-model="create.temp.productdate" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 100%;" :clearable="false" :disabled="create.dialogStatus=='update'" />
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="6">
  151. <el-form-item label="记录人:" prop="emp">
  152. <el-select ref="emp" v-model="create.temp.emp" :disabled="create.dialogStatus=='update'" filterable placeholder="记录人" class="filter-item" style="width: 100%;" @blur="blurEmp">
  153. <el-option v-for="item in create.noteTakerList" :key="item.myId" :label="item.emp" :value="item.emp" />
  154. </el-select>
  155. </el-form-item>
  156. </el-col>
  157. </el-row>
  158. <el-row>
  159. <el-col :span="24">
  160. <h3 style="width: 160px;text-align: right;">栏舍信息</h3>
  161. </el-col>
  162. </el-row>
  163. <el-row>
  164. <el-col v-if="create.dialogStatus=='create'" :span="6">
  165. <el-form-item label="栏舍名称:" prop="barid">
  166. <el-select v-model="create.temp.barid" filterable placeholder="栏舍名称" class="filter-item" style="width: 100%;" @change="changeBar">
  167. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  168. </el-select>
  169. </el-form-item>
  170. </el-col>
  171. <el-col v-else :span="6">
  172. <el-form-item label="栏舍名称:" prop="barname">
  173. <el-input ref="barname" v-model="create.temp.barname" disabled class="filter-item" placeholder="barname" />
  174. </el-form-item>
  175. </el-col>
  176. <el-col :span="6">
  177. <el-form-item label="牲畜类别:" prop="cowclassid">
  178. <el-select v-model="create.temp.cowclassid" :disabled="create.dialogStatus=='update'" filterable placeholder="牲畜类别" class="filter-item" style="width: 100%;" @change="changeCowclass">
  179. <el-option v-for="item in livestockList" :key="item.id" :label="item.mixname" :value="item.id" />
  180. </el-select>
  181. </el-form-item>
  182. </el-col>
  183. <el-col :span="6">
  184. <el-form-item label="牛头数:" prop="cowsum">
  185. <el-input ref="cowsum" v-model="create.temp.cowsum" class="filter-item" placeholder="正整数" type="number" step="0.01" />
  186. </el-form-item>
  187. </el-col>
  188. <el-col :span="6">
  189. <el-form-item label="环境温度(℃):" prop="tem">
  190. <el-input v-model="create.temp.tem" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" />
  191. </el-form-item>
  192. </el-col>
  193. </el-row>
  194. <el-row>
  195. <el-col :span="24">
  196. <h3 style="width: 160px;text-align: right;">牛只基础信息</h3>
  197. </el-col>
  198. </el-row>
  199. <el-row>
  200. <el-col :span="6">
  201. <el-form-item label="平均月龄:" prop="avgmonthage">
  202. <el-input ref="avgmonthage" v-model="create.temp.avgmonthage" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" />
  203. </el-form-item>
  204. </el-col>
  205. <el-col :span="6">
  206. <el-form-item label="体重(kg):" prop="bw">
  207. <el-input ref="bw" v-model="create.temp.bw" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" />
  208. </el-form-item>
  209. </el-col>
  210. <el-col :span="6">
  211. <el-form-item label="日增重(kg):" prop="dayw">
  212. <el-input ref="dayw" v-model="create.temp.dayw" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" />
  213. </el-form-item>
  214. </el-col>
  215. <el-col :span="6">
  216. <el-form-item label="怀孕天数:" prop="dayspre">
  217. <el-input ref="dayspre" v-model="create.temp.dayspre" class="filter-item" placeholder="0-280整数" type="number" />
  218. </el-form-item>
  219. </el-col>
  220. </el-row>
  221. <el-row>
  222. <el-col :span="6">
  223. <el-form-item label="胎次:" prop="fetal">
  224. <el-input ref="fetal" v-model="create.temp.fetal" :disabled="create.temp.bigcowclass=='后备牛' " class="filter-item" placeholder="0-20整数" type="number" />
  225. </el-form-item>
  226. </el-col>
  227. <el-col :span="6">
  228. <el-form-item label="平均泌乳天数:" prop="avgdim">
  229. <el-input ref="avgdim" v-model="create.temp.avgdim" :disabled="create.temp.bigcowclass=='后备牛' || create.temp.bigcowclass=='干奶牛'" class="filter-item" placeholder="正整数" type="number" />
  230. </el-form-item>
  231. </el-col>
  232. <el-col :span="6">
  233. <el-form-item label="产奶量(kg/头):" prop="product">
  234. <el-input ref="product" v-model="create.temp.product" :disabled="create.temp.bigcowclass=='后备牛' || create.temp.bigcowclass=='干奶牛'" class="filter-item" placeholder="最多两位小数" type="number" />
  235. </el-form-item>
  236. </el-col>
  237. <el-col :span="6">
  238. <el-form-item label="乳脂率(%)" prop="fat">
  239. <el-input ref="fat" v-model="create.temp.fat" :disabled="create.temp.bigcowclass=='后备牛' || create.temp.bigcowclass=='干奶牛'" class="filter-item" placeholder="最多两位小数" type="number" />
  240. </el-form-item>
  241. </el-col>
  242. </el-row>
  243. <el-row>
  244. <el-col :span="6">
  245. <el-form-item label="乳蛋白率(%):" prop="pro">
  246. <el-input ref="pro" v-model="create.temp.pro" :disabled="create.temp.bigcowclass=='后备牛' || create.temp.bigcowclass=='干奶牛'" class="filter-item" placeholder="最多两位小数" type="number" />
  247. </el-form-item>
  248. </el-col>
  249. <el-col :span="6">
  250. <el-form-item label="乳糖率(%):" prop="lactose">
  251. <el-input ref="lactose" v-model="create.temp.lactose" :disabled="create.temp.bigcowclass=='后备牛' || create.temp.bigcowclass=='干奶牛'" class="filter-item" placeholder="最多两位小数" type="number" />
  252. </el-form-item>
  253. </el-col>
  254. </el-row>
  255. </el-form>
  256. <div slot="footer" class="dialog-footer">
  257. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  258. <el-button v-if="create.dialogStatus==='create'" class="success" :disabled="isokDisable" @click="createDataAgain()">确认新增</el-button>
  259. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  260. </div>
  261. </div>
  262. </el-dialog>
  263. </div>
  264. </template>
  265. <script>
  266. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  267. import Cookies from 'js-cookie'
  268. import { parseTime, json2excel } from '@/utils/index.js'
  269. import Pagination from '@/components/Pagination'
  270. import { MessageBox } from 'element-ui'
  271. import { getToken } from '@/utils/auth'
  272. export default {
  273. name: 'Performance',
  274. components: { Pagination },
  275. data() {
  276. return {
  277. isRoleEdit: [],
  278. requestParams: [
  279. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }},
  280. { name: 'getCowclassListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }}
  281. ],
  282. houseNameList: [], // 栏舍名称
  283. livestockList: [], // 牲畜类别
  284. table: {
  285. getdataListParm: {
  286. name: 'getBarmilkList',
  287. page: 1,
  288. offset: 1,
  289. pagecount: 10,
  290. returntype: 'Map',
  291. parammaps: {
  292. pastureid: Cookies.get('pastureid'),
  293. barid: '',
  294. cowclass: '',
  295. startTime: '',
  296. stopTime: '',
  297. inputDatetime: ''
  298. }
  299. },
  300. tableKey: 0,
  301. list: [],
  302. total: 0,
  303. listLoading: true,
  304. temp: {}
  305. },
  306. // 新增/编辑
  307. create: {
  308. dialogFormVisible: false,
  309. dialogStatus: '',
  310. temp: { pastureid: Cookies.get('pastureid'), productdate: parseTime(new Date(), '{y}-{m}-{d}'), emp: Cookies.get('employename'), barid: '', barname: '', cowclassid: '', cowclass: '', bigcowclass: '', cowsum: '', tem: '', avgmonthage: '', bw: '', dayw: '', dayspre: '', fetal: '', avgdim: '', product: '', fat: '', pro: '', lactose: '' },
  311. rules: {
  312. barid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  313. cowclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  314. },
  315. getdataListParm: {
  316. name: 'getBarmilkEmpHis',
  317. page: 1,
  318. offset: 1,
  319. pagecount: 10,
  320. returntype: 'Map',
  321. parammaps: {
  322. pastureid: Cookies.get('pastureid')
  323. }
  324. },
  325. noteTakerList: [] // 记录人
  326. },
  327. textMap: {
  328. create: '新增',
  329. update: '编辑'
  330. },
  331. requestParam: {},
  332. download: {
  333. getdataListParm: {
  334. name: 'getBarmilkList',
  335. page: 1,
  336. offset: 1,
  337. pagecount: 0,
  338. returntype: 'Map',
  339. parammaps: {
  340. pastureid: Cookies.get('pastureid'),
  341. barid: '',
  342. cowclass: '',
  343. startTime: '',
  344. stopTime: '',
  345. inputDatetime: ''
  346. }
  347. },
  348. list: []
  349. },
  350. isokDisable: false,
  351. selectList: [],
  352. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  353. cellStyle: { padding: 0 + 'px' }
  354. }
  355. },
  356. computed: {
  357. // 设置请求头
  358. headers() {
  359. return {
  360. token: getToken()
  361. }
  362. },
  363. uploadData() {
  364. return {
  365. name: '颛孙洋洋-栏舍生产性能',
  366. importParams: '栏舍名称,牲畜类别,牛头数,环境温度(℃),平均月龄,体重(kg),日增重(kg),怀孕天数,胎次,平均泌乳天数,产奶量(kg/头),乳脂率(%),乳蛋白率(%),乳糖率(%),记录人,生效日期',
  367. sheetname: 'SheetJS'
  368. }
  369. },
  370. // 设置上传地址
  371. uploadExcelUrl() {
  372. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  373. }
  374. },
  375. created() {
  376. this.getList()
  377. this.getDownList()
  378. this.getButtons()
  379. },
  380. methods: {
  381. getButtons() {
  382. const Edit = 'Performance'
  383. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  384. this.isRoleEdit = isRoleEdit
  385. },
  386. getDownList() {
  387. GetDataByNames(this.requestParams).then(response => {
  388. this.houseNameList = response.data.getBarListEnable.list
  389. this.livestockList = response.data.getCowclassListEnable.list
  390. })
  391. },
  392. handleBefore() {
  393. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  394. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  395. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  396. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  397. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  398. this.$forceUpdate()
  399. }
  400. },
  401. handleNext() {
  402. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  403. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  404. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  405. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  406. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  407. this.$forceUpdate()
  408. }
  409. },
  410. getList() {
  411. this.table.listLoading = true
  412. GetDataByName(this.table.getdataListParm).then(response => {
  413. console.log('table数据', response.data.list)
  414. if (response.data.list !== null) {
  415. this.table.list = response.data.list
  416. this.table.pageNum = response.data.pageNum
  417. this.table.pageSize = response.data.pageSize
  418. this.table.total = response.data.total
  419. } else {
  420. this.table.list = []
  421. }
  422. setTimeout(() => {
  423. this.table.listLoading = false
  424. }, 100)
  425. })
  426. },
  427. handleSearch() {
  428. console.log('点击了查询')
  429. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  430. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  431. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  432. } else {
  433. this.table.getdataListParm.parammaps.inputDatetime = ''
  434. this.table.getdataListParm.parammaps.startTime = ''
  435. this.table.getdataListParm.parammaps.stopTime = ''
  436. }
  437. this.table.getdataListParm.offset = 1
  438. this.getList()
  439. },
  440. handleRefresh() {
  441. console.log('点击了重置')
  442. this.table.getdataListParm.parammaps.barid = ''
  443. this.table.getdataListParm.parammaps.cowclass = ''
  444. this.table.getdataListParm.parammaps.startTime = ''
  445. this.table.getdataListParm.parammaps.stopTime = ''
  446. this.table.getdataListParm.parammaps.inputDatetime = ''
  447. this.table.getdataListParm.offset = 1
  448. this.getList()
  449. },
  450. // 新增
  451. resetTemp() {
  452. this.create.temp = { pastureid: Cookies.get('pastureid'), productdate: parseTime(new Date(), '{y}-{m}-{d}'), emp: Cookies.get('employename'), barid: '', barname: '', cowclassid: '', cowclass: '', bigcowclass: '', cowsum: '', tem: '', avgmonthage: '', bw: '', dayw: '', dayspre: '', fetal: '', avgdim: '', product: '', fat: '', pro: '', lactose: '' }
  453. },
  454. blurEmp(item) {
  455. this.create.temp.emp = item.target.value
  456. },
  457. // 栏舍名称
  458. changeBar(item) {
  459. this.create.temp.barname = this.houseNameList.find(obj => obj.id === item).bname
  460. },
  461. // 牲畜类别
  462. changeCowclass(item) {
  463. this.create.temp.cowclass = this.livestockList.find(obj => obj.id === item).classname
  464. this.create.temp.bigcowclass = this.livestockList.find(obj => obj.id === item).parentname
  465. },
  466. getNoteTakerList() {
  467. GetDataByName(this.create.getdataListParm).then(response => {
  468. if (response.data.list !== null) {
  469. for (let i = 0; i < response.data.list.length; i++) {
  470. response.data.list[i].myId = i
  471. }
  472. this.create.noteTakerList = response.data.list
  473. console.log('记录人数据', response.data.list)
  474. console.log(this.create.noteTakerList)
  475. } else {
  476. this.create.noteTakerList = []
  477. }
  478. })
  479. },
  480. handleCreate() {
  481. console.log('点击了新增')
  482. this.resetTemp()
  483. this.getNoteTakerList()
  484. this.create.dialogStatus = 'create'
  485. this.create.dialogFormVisible = true
  486. },
  487. createData() {
  488. console.log('点击了新增保存')
  489. this.isokDisable = true
  490. setTimeout(() => {
  491. this.isokDisable = false
  492. }, 1000)
  493. this.$refs['temp'].validate(valid => {
  494. if (valid) {
  495. this.isokDisable = true
  496. setTimeout(() => {
  497. this.isokDisable = false
  498. }, 1000)
  499. const positiveInteger = /^[1-9]\d*$/
  500. // 牛头数
  501. if (this.create.temp.cowsum !== '') {
  502. if (!positiveInteger.test(parseFloat(this.create.temp.cowsum))) {
  503. this.$message({ type: 'error', message: '牛头数请输入正整数', duration: 2000 })
  504. return false
  505. }
  506. }
  507. const twoDecimalPlaces = /^\d+(\.\d{1,2})?$/
  508. // 温度环境
  509. if (this.create.temp.tem !== '') {
  510. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.tem))) {
  511. this.$message({ type: 'error', message: '温度环境请保留两位小数', duration: 2000 })
  512. return false
  513. }
  514. }
  515. // 平均月龄
  516. if (this.create.temp.avgmonthage !== '') {
  517. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.avgmonthage))) {
  518. this.$message({ type: 'error', message: '平均月龄请保留两位小数', duration: 2000 })
  519. return false
  520. }
  521. }
  522. // 体重
  523. if (this.create.temp.bw !== '') {
  524. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.bw))) {
  525. this.$message({ type: 'error', message: '体重请保留两位小数', duration: 2000 })
  526. return false
  527. }
  528. }
  529. // 日增重
  530. if (this.create.temp.dayw !== '') {
  531. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.dayw))) {
  532. this.$message({ type: 'error', message: '日增重请保留两位小数', duration: 2000 })
  533. return false
  534. }
  535. }
  536. const dayspre = /^(([1-9]|([1-9]\d)|(1\d\d)|(2([0-7]\d|7[0-9]))))$/
  537. // 怀孕天数
  538. if (this.create.temp.dayspre !== '') {
  539. if (!dayspre.test(parseFloat(this.create.temp.dayspre))) {
  540. this.$message({ type: 'error', message: '怀孕天数请输入大于0小于280整数', duration: 2000 })
  541. return false
  542. }
  543. }
  544. const fetal = /^(?:[1-9]|1[0-9])$/
  545. // 胎次
  546. if (this.create.temp.fetal !== '') {
  547. if (!fetal.test(parseFloat(this.create.temp.fetal))) {
  548. this.$message({ type: 'error', message: '胎次请输入大于0小于20整数', duration: 2000 })
  549. return false
  550. }
  551. }
  552. // 平均泌乳
  553. if (this.create.temp.avgdim !== '') {
  554. if (!positiveInteger.test(parseFloat(this.create.temp.avgdim))) {
  555. this.$message({ type: 'error', message: '平均泌乳天数请输入正整数', duration: 2000 })
  556. return false
  557. }
  558. }
  559. // 产奶量
  560. if (this.create.temp.product !== '') {
  561. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.product))) {
  562. this.$message({ type: 'error', message: '产奶量请保留两位小数', duration: 2000 })
  563. return false
  564. }
  565. }
  566. // 乳脂率
  567. if (this.create.temp.fat !== '') {
  568. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.fat))) {
  569. this.$message({ type: 'error', message: '乳脂率请保留两位小数', duration: 2000 })
  570. return false
  571. }
  572. }
  573. // 乳蛋白率
  574. if (this.create.temp.pro !== '') {
  575. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.pro))) {
  576. this.$message({ type: 'error', message: '乳蛋白率请保留两位小数', duration: 2000 })
  577. return false
  578. }
  579. }
  580. // 乳糖率
  581. if (this.create.temp.lactose !== '') {
  582. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.lactose))) {
  583. this.$message({ type: 'error', message: '乳糖率请保留两位小数', duration: 2000 })
  584. return false
  585. }
  586. }
  587. this.requestParam.name = 'insertBarmilk'
  588. this.requestParam.parammaps = this.create.temp
  589. if (this.create.temp.cowsum == '') { this.create.temp.cowsum = '0' }
  590. if (this.create.temp.tem == '') { this.create.temp.tem = '0' }
  591. if (this.create.temp.avgmonthage == '') { this.create.temp.avgmonthage = '0' }
  592. if (this.create.temp.bw == '') { this.create.temp.bw = '0' }
  593. if (this.create.temp.dayw == '') { this.create.temp.dayw = '0' }
  594. if (this.create.temp.dayspre == '') { this.create.temp.dayspre = '0' }
  595. if (this.create.temp.fetal == '') { this.create.temp.fetal = '0' }
  596. if (this.create.temp.avgdim == '') { this.create.temp.avgdim = '0' }
  597. if (this.create.temp.product == '') { this.create.temp.product = '0' }
  598. if (this.create.temp.fat == '') { this.create.temp.fat = '0' }
  599. if (this.create.temp.pro == '') { this.create.temp.pro = '0' }
  600. if (this.create.temp.lactose == '') { this.create.temp.lactose = '0' }
  601. PostDataByName(this.requestParam).then(response => {
  602. console.log('新增保存发送参数', this.requestParam)
  603. if (response.msg !== 'fail') {
  604. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  605. this.create.dialogFormVisible = false
  606. this.getList()
  607. } else {
  608. const barid = new RegExp("key 'barid'")
  609. if (barid.test(response.data)) {
  610. this.$message({ type: 'error', message: '该栏舍今日生产性能已存在,不可重复生成', duration: 2000 })
  611. } else {
  612. failproccess(response, this.$notify)
  613. }
  614. if (this.create.temp.cowsum == '0') { this.create.temp.cowsum = '' }
  615. if (this.create.temp.tem == '0') { this.create.temp.tem = '' }
  616. if (this.create.temp.avgmonthage == '0') { this.create.temp.avgmonthage = '' }
  617. if (this.create.temp.bw == '0') { this.create.temp.bw = '' }
  618. if (this.create.temp.dayw == '0') { this.create.temp.dayw = '' }
  619. if (this.create.temp.dayspre == '0') { this.create.temp.dayspre = '' }
  620. if (this.create.temp.fetal == '0') { this.create.temp.fetal = '' }
  621. if (this.create.temp.avgdim == '0') { this.create.temp.avgdim = '' }
  622. if (this.create.temp.product == '0') { this.create.temp.product = '' }
  623. if (this.create.temp.fat == '0') { this.create.temp.fat = '' }
  624. if (this.create.temp.pro == '0') { this.create.temp.pro = '' }
  625. if (this.create.temp.lactose == '0') { this.create.temp.lactose = '' }
  626. }
  627. })
  628. }
  629. })
  630. },
  631. createDataAgain() {
  632. console.log('点击了新增保存')
  633. this.isokDisable = true
  634. setTimeout(() => {
  635. this.isokDisable = false
  636. }, 1000)
  637. this.$refs['temp'].validate(valid => {
  638. if (valid) {
  639. this.isokDisable = true
  640. setTimeout(() => {
  641. this.isokDisable = false
  642. }, 1000)
  643. const positiveInteger = /^[1-9]\d*$/
  644. // 牛头数
  645. if (this.create.temp.cowsum !== '') {
  646. if (!positiveInteger.test(parseFloat(this.create.temp.cowsum))) {
  647. this.$message({ type: 'error', message: '牛头数请输入正整数', duration: 2000 })
  648. return false
  649. }
  650. }
  651. const twoDecimalPlaces = /^\d+(\.\d{1,2})?$/
  652. // 温度环境
  653. if (this.create.temp.tem !== '') {
  654. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.tem))) {
  655. this.$message({ type: 'error', message: '温度环境请保留两位小数', duration: 2000 })
  656. return false
  657. }
  658. }
  659. // 平均月龄
  660. if (this.create.temp.avgmonthage !== '') {
  661. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.avgmonthage))) {
  662. this.$message({ type: 'error', message: '平均月龄请保留两位小数', duration: 2000 })
  663. return false
  664. }
  665. }
  666. // 体重
  667. if (this.create.temp.bw !== '') {
  668. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.bw))) {
  669. this.$message({ type: 'error', message: '体重请保留两位小数', duration: 2000 })
  670. return false
  671. }
  672. }
  673. // 日增重
  674. if (this.create.temp.dayw !== '') {
  675. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.dayw))) {
  676. this.$message({ type: 'error', message: '日增重请保留两位小数', duration: 2000 })
  677. return false
  678. }
  679. }
  680. const dayspre = /^(([1-9]|([1-9]\d)|(1\d\d)|(2([0-7]\d|7[0-9]))))$/
  681. // 怀孕天数
  682. if (this.create.temp.dayspre !== '') {
  683. if (!dayspre.test(parseFloat(this.create.temp.dayspre))) {
  684. this.$message({ type: 'error', message: '怀孕天数请输入大于0小于280整数', duration: 2000 })
  685. return false
  686. }
  687. }
  688. const fetal = /^(?:[1-9]|1[0-9])$/
  689. // 胎次
  690. if (this.create.temp.fetal !== '') {
  691. if (!fetal.test(parseFloat(this.create.temp.fetal))) {
  692. this.$message({ type: 'error', message: '胎次请输入大于0小于20整数', duration: 2000 })
  693. return false
  694. }
  695. }
  696. // 平均泌乳
  697. if (this.create.temp.avgdim !== '') {
  698. if (!positiveInteger.test(parseFloat(this.create.temp.avgdim))) {
  699. this.$message({ type: 'error', message: '平均泌乳天数请输入正整数', duration: 2000 })
  700. return false
  701. }
  702. }
  703. // 产奶量
  704. if (this.create.temp.product !== '') {
  705. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.product))) {
  706. this.$message({ type: 'error', message: '产奶量请保留两位小数', duration: 2000 })
  707. return false
  708. }
  709. }
  710. // 乳脂率
  711. if (this.create.temp.fat !== '') {
  712. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.fat))) {
  713. this.$message({ type: 'error', message: '乳脂率请保留两位小数', duration: 2000 })
  714. return false
  715. }
  716. }
  717. // 乳蛋白率
  718. if (this.create.temp.pro !== '') {
  719. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.pro))) {
  720. this.$message({ type: 'error', message: '乳蛋白率请保留两位小数', duration: 2000 })
  721. return false
  722. }
  723. }
  724. // 乳糖率
  725. if (this.create.temp.lactose !== '') {
  726. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.lactose))) {
  727. this.$message({ type: 'error', message: '乳糖率请保留两位小数', duration: 2000 })
  728. return false
  729. }
  730. }
  731. this.requestParam.name = 'insertBarmilk'
  732. this.requestParam.parammaps = this.create.temp
  733. if (this.create.temp.cowsum == '') { this.create.temp.cowsum = '0' }
  734. if (this.create.temp.tem == '') { this.create.temp.tem = '0' }
  735. if (this.create.temp.avgmonthage == '') { this.create.temp.avgmonthage = '0' }
  736. if (this.create.temp.bw == '') { this.create.temp.bw = '0' }
  737. if (this.create.temp.dayw == '') { this.create.temp.dayw = '0' }
  738. if (this.create.temp.dayspre == '') { this.create.temp.dayspre = '0' }
  739. if (this.create.temp.fetal == '') { this.create.temp.fetal = '0' }
  740. if (this.create.temp.avgdim == '') { this.create.temp.avgdim = '0' }
  741. if (this.create.temp.product == '') { this.create.temp.product = '0' }
  742. if (this.create.temp.fat == '') { this.create.temp.fat = '0' }
  743. if (this.create.temp.pro == '') { this.create.temp.pro = '0' }
  744. if (this.create.temp.lactose == '') { this.create.temp.lactose = '0' }
  745. PostDataByName(this.requestParam).then(response => {
  746. console.log('新增保存发送参数', this.requestParam)
  747. if (response.msg !== 'fail') {
  748. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  749. this.resetTemp()
  750. this.create.noteTakerList = []
  751. this.getNoteTakerList()
  752. } else {
  753. const barid = new RegExp("key 'barid'")
  754. if (barid.test(response.data)) {
  755. this.$message({ type: 'error', message: '该栏舍今日生产性能已存在,不可重复生成', duration: 2000 })
  756. } else {
  757. failproccess(response, this.$notify)
  758. }
  759. if (this.create.temp.cowsum == '0') { this.create.temp.cowsum = '' }
  760. if (this.create.temp.tem == '0') { this.create.temp.tem = '' }
  761. if (this.create.temp.avgmonthage == '0') { this.create.temp.avgmonthage = '' }
  762. if (this.create.temp.bw == '0') { this.create.temp.bw = '' }
  763. if (this.create.temp.dayw == '0') { this.create.temp.dayw = '' }
  764. if (this.create.temp.dayspre == '0') { this.create.temp.dayspre = '' }
  765. if (this.create.temp.fetal == '0') { this.create.temp.fetal = '' }
  766. if (this.create.temp.avgdim == '0') { this.create.temp.avgdim = '' }
  767. if (this.create.temp.product == '0') { this.create.temp.product = '' }
  768. if (this.create.temp.fat == '0') { this.create.temp.fat = '' }
  769. if (this.create.temp.pro == '0') { this.create.temp.pro = '' }
  770. if (this.create.temp.lactose == '0') { this.create.temp.lactose = '' }
  771. }
  772. })
  773. }
  774. })
  775. },
  776. // 编辑
  777. handleUpdate(row) {
  778. console.log('点击了编辑', row)
  779. row.barid = String(row.barid)
  780. row.cowclassid = String(row.cowclassid)
  781. this.create.temp = Object.assign({}, row)
  782. this.create.temp.id = row.id
  783. if (this.create.temp.cowsum == '0') { this.create.temp.cowsum = '' }
  784. if (this.create.temp.avgdim == '0') { this.create.temp.avgdim = '' }
  785. if (this.create.temp.dayspre == '0') { this.create.temp.dayspre = '' }
  786. if (this.create.temp.fetal == '0') { this.create.temp.fetal = '' }
  787. this.getNoteTakerList()
  788. this.create.dialogStatus = 'update'
  789. this.create.dialogFormVisible = true
  790. },
  791. updateData() {
  792. this.isokDisable = true
  793. setTimeout(() => {
  794. this.isokDisable = false
  795. }, 1000)
  796. this.$refs['temp'].validate(valid => {
  797. if (valid) {
  798. this.isokDisable = true
  799. setTimeout(() => {
  800. this.isokDisable = false
  801. }, 1000)
  802. const positiveInteger = /^[1-9]\d*$/
  803. // 牛头数
  804. if (this.create.temp.cowsum !== '') {
  805. if (!positiveInteger.test(parseFloat(this.create.temp.cowsum))) {
  806. this.$message({ type: 'error', message: '牛头数请输入正整数', duration: 2000 })
  807. return false
  808. }
  809. }
  810. const twoDecimalPlaces = /^\d+(\.\d{1,2})?$/
  811. // 温度环境
  812. if (this.create.temp.tem !== '') {
  813. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.tem))) {
  814. this.$message({ type: 'error', message: '温度环境请保留两位小数', duration: 2000 })
  815. return false
  816. }
  817. }
  818. // 平均月龄
  819. if (this.create.temp.avgmonthage !== '') {
  820. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.avgmonthage))) {
  821. this.$message({ type: 'error', message: '平均月龄请保留两位小数', duration: 2000 })
  822. return false
  823. }
  824. }
  825. // 体重
  826. if (this.create.temp.bw !== '') {
  827. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.bw))) {
  828. this.$message({ type: 'error', message: '体重请保留两位小数', duration: 2000 })
  829. return false
  830. }
  831. }
  832. // 日增重
  833. if (this.create.temp.dayw !== '') {
  834. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.dayw))) {
  835. this.$message({ type: 'error', message: '日增重请保留两位小数', duration: 2000 })
  836. return false
  837. }
  838. }
  839. const dayspre = /^(([1-9]|([1-9]\d)|(1\d\d)|(2([0-7]\d|7[0-9]))))$/
  840. // 怀孕天数
  841. if (this.create.temp.dayspre !== '') {
  842. if (!dayspre.test(parseFloat(this.create.temp.dayspre))) {
  843. this.$message({ type: 'error', message: '怀孕天数请输入大于0小于280整数', duration: 2000 })
  844. return false
  845. }
  846. }
  847. const fetal = /^(?:[1-9]|1[0-9])$/
  848. // 胎次
  849. if (this.create.temp.fetal !== '') {
  850. if (!fetal.test(parseFloat(this.create.temp.fetal))) {
  851. this.$message({ type: 'error', message: '胎次请输入大于0小于20整数', duration: 2000 })
  852. return false
  853. }
  854. }
  855. // 平均泌乳
  856. if (this.create.temp.avgdim !== '') {
  857. if (!positiveInteger.test(parseFloat(this.create.temp.avgdim))) {
  858. this.$message({ type: 'error', message: '平均泌乳天数请输入正整数', duration: 2000 })
  859. return false
  860. }
  861. }
  862. // 产奶量
  863. if (this.create.temp.product !== '') {
  864. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.product))) {
  865. this.$message({ type: 'error', message: '产奶量请保留两位小数', duration: 2000 })
  866. return false
  867. }
  868. }
  869. // 乳脂率
  870. if (this.create.temp.fat !== '') {
  871. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.fat))) {
  872. this.$message({ type: 'error', message: '乳脂率请保留两位小数', duration: 2000 })
  873. return false
  874. }
  875. }
  876. // 乳蛋白率
  877. if (this.create.temp.pro !== '') {
  878. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.pro))) {
  879. this.$message({ type: 'error', message: '乳蛋白率请保留两位小数', duration: 2000 })
  880. return false
  881. }
  882. }
  883. // 乳糖率
  884. if (this.create.temp.lactose !== '') {
  885. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.lactose))) {
  886. this.$message({ type: 'error', message: '乳糖率请保留两位小数', duration: 2000 })
  887. return false
  888. }
  889. }
  890. this.requestParam.name = 'updateBarmilk'
  891. this.requestParam.parammaps = this.create.temp
  892. if (this.create.temp.cowsum == '') { this.create.temp.cowsum = '0' }
  893. if (this.create.temp.tem == '') { this.create.temp.tem = '0' }
  894. if (this.create.temp.avgmonthage == '') { this.create.temp.avgmonthage = '0' }
  895. if (this.create.temp.bw == '') { this.create.temp.bw = '0' }
  896. if (this.create.temp.dayw == '') { this.create.temp.dayw = '0' }
  897. if (this.create.temp.dayspre == '') { this.create.temp.dayspre = '0' }
  898. if (this.create.temp.fetal == '') { this.create.temp.fetal = '0' }
  899. if (this.create.temp.avgdim == '') { this.create.temp.avgdim = '0' }
  900. if (this.create.temp.product == '') { this.create.temp.product = '0' }
  901. if (this.create.temp.fat == '') { this.create.temp.fat = '0' }
  902. if (this.create.temp.pro == '') { this.create.temp.pro = '0' }
  903. if (this.create.temp.lactose == '') { this.create.temp.lactose = '0' }
  904. PostDataByName(this.requestParam).then(response => {
  905. console.log('新增保存发送参数', this.requestParam)
  906. if (response.msg !== 'fail') {
  907. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  908. this.create.dialogFormVisible = false
  909. this.getList()
  910. } else {
  911. failproccess(response, this.$notify)
  912. if (this.create.temp.dayspre == '0') { this.create.temp.dayspre = '' }
  913. if (this.create.temp.fetal == '0') { this.create.temp.fetal = '' }
  914. if (this.create.temp.cowsum == '0') { this.create.temp.cowsum = '' }
  915. if (this.create.temp.avgdim == '0') { this.create.temp.avgdim = '' }
  916. }
  917. })
  918. }
  919. })
  920. },
  921. // 删除
  922. handleRowDelete(row) {
  923. console.log('点击了行内删除')
  924. MessageBox.confirm('是否确认删除此信息?', {
  925. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  926. }).then(() => {
  927. this.selectList = []
  928. this.requestParam.name = 'deleteBarmilk'
  929. this.requestParam.parammaps = {}
  930. this.requestParam.parammaps.pastureid = row.pastureid
  931. this.requestParam.parammaps.id = row.id
  932. PostDataByName(this.requestParam).then(response => {
  933. if (response.msg === 'fail') {
  934. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  935. } else {
  936. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  937. this.getList()
  938. }
  939. })
  940. }).catch(() => {
  941. this.$message({ type: 'info', message: '已取消删除' })
  942. })
  943. },
  944. handleSelectionChange(val) {
  945. console.log('勾选数据', val)
  946. this.selectList = val
  947. },
  948. handleDelete() {
  949. console.log('点击了删除')
  950. if (this.selectList.length == 0) {
  951. this.$message({ type: 'error', message: '请选择栏舍生产性能', duration: 2000 })
  952. } else {
  953. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  954. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  955. }).then(() => {
  956. console.log(this.selectList)
  957. this.requestParam.common = { 'returnmap': '0' }
  958. this.requestParam.data = []
  959. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  960. this.requestParam.data[0].children = []
  961. this.requestParam.data[0].children[0] = { 'name': 'deleteBarmilk', 'type': 'e', 'parammaps': {
  962. id: '@insertSpotList.id',
  963. pastureid: '@insertSpotList.pastureid'
  964. }}
  965. ExecDataByConfig(this.requestParam).then(response => {
  966. console.log('删除保存发送参数', this.requestParam)
  967. if (response.msg === 'fail') {
  968. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  969. } else {
  970. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  971. this.getList()
  972. }
  973. })
  974. })
  975. }
  976. },
  977. // 复制
  978. handleCopy() {
  979. console.log('点击了复制')
  980. if (this.selectList.length == 0) {
  981. this.$message({ type: 'error', message: '请选择栏舍生产性能', duration: 2000 })
  982. } else if (this.selectList.length == 1) {
  983. MessageBox.confirm('是否确认复制此信息?', {
  984. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  985. }).then(() => {
  986. this.requestParam.name = 'copybarmilk'
  987. this.requestParam.parammaps = {}
  988. this.requestParam.parammaps.pastureid = this.selectList[0].pastureid
  989. this.requestParam.parammaps.id = this.selectList[0].id
  990. PostDataByName(this.requestParam).then(response => {
  991. if (response.msg === 'fail') {
  992. const barid = new RegExp("key 'barid'")
  993. if (barid.test(response.data)) {
  994. this.$message({ type: 'error', message: '该栏舍今日生产性能已存在,不可重复生成', duration: 2000 })
  995. } else {
  996. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  997. }
  998. } else {
  999. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1000. this.getList()
  1001. }
  1002. })
  1003. }).catch(() => {
  1004. this.$message({ type: 'info', message: '已取消删除' })
  1005. })
  1006. } else {
  1007. this.$message({ type: 'error', message: '请选择一条栏舍生产性能', duration: 2000 })
  1008. }
  1009. },
  1010. // 导出
  1011. handleExport(item) {
  1012. if (item == 1) {
  1013. console.log('点击了导出模板')
  1014. } else {
  1015. console.log('点击了导出数据')
  1016. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1017. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  1018. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  1019. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  1020. } else {
  1021. this.download.getdataListParm.parammaps.inputDatetime = ''
  1022. this.download.getdataListParm.parammaps.startTime = ''
  1023. this.download.getdataListParm.parammaps.stopTime = ''
  1024. }
  1025. GetDataByName(this.download.getdataListParm).then(response => {
  1026. if (response.data.list !== null) {
  1027. this.download.list = response.data.list
  1028. } else {
  1029. this.download.list = []
  1030. }
  1031. var excelDatas = [
  1032. {
  1033. tHeader: ['栏舍名称', '牲畜类别', '牛头数', '环境温度(℃)', '平均月龄', '体重(kg)', '日增重(kg)', '怀孕天数', '胎次', '平均泌乳天数', '产奶量(kg/头)', '乳脂率(%)', '乳蛋白率(%)', '乳糖率(%)', '记录人', '生效日期'],
  1034. filterVal: ['barname', 'cowclass', 'cowsum', 'tem', 'avgmonthage', 'bw', 'dayw', 'dayspre', 'fetal', 'avgdim', 'product', 'fat', 'pro', 'lactose', 'emp', 'productdate'],
  1035. tableDatas: this.download.list,
  1036. sheetName: 'Sheet1'
  1037. }
  1038. ]
  1039. json2excel(excelDatas, '栏舍生产性能', true, 'xlsx')
  1040. })
  1041. }
  1042. },
  1043. beforeImport(file) {
  1044. const isLt2M = file.size / 1024 / 1024 < 2
  1045. if (!isLt2M) {
  1046. this.$message.error('上传文件大小不能超过 2MB!')
  1047. }
  1048. return isLt2M
  1049. },
  1050. handleImportSuccess(res, file) {
  1051. this.getList()
  1052. if (res.msg === 'ok') {
  1053. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1054. if (res.data.err_count > 0) {
  1055. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1056. import('@/vendor/Export2Excel').then(excel => {
  1057. const list1 = res.data.result
  1058. const tHeader = [
  1059. '栏舍名称', '牲畜类别', '牛头数 ', '环境温度(℃)', '平均月龄', '体重(kg)', '日增重(kg)', '怀孕天数', '胎次', '平均泌乳天数', '产奶量(kg/头)', '乳脂率(%)', '乳蛋白率(%)', '乳糖率(%)', '记录人', '生效日期', '错误信息'
  1060. ]
  1061. const filterVal = [
  1062. '栏舍名称', '牲畜类别', '牛头数 ', '环境温度(℃)', '平均月龄', '体重(kg)', '日增重(kg)', '怀孕天数', '胎次', '平均泌乳天数', '产奶量(kg/头)', '乳脂率(%)', '乳蛋白率(%)', '乳糖率(%)', '记录人', '生效日期', 'error_msg'
  1063. ]
  1064. const data1 = this.formatJson(filterVal, list1)
  1065. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '栏舍生产性能导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1066. })
  1067. }
  1068. } else {
  1069. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1070. }
  1071. },
  1072. formatJson(filterVal, jsonData) {
  1073. return jsonData.map(v =>
  1074. filterVal.map(j => {
  1075. if (j === 'timestamp') {
  1076. return parseTime(v[j])
  1077. } else {
  1078. return v[j]
  1079. }
  1080. })
  1081. )
  1082. }
  1083. }
  1084. }
  1085. </script>
  1086. <style lang="scss" scoped>
  1087. .search{padding-top:10px;clear: both;}
  1088. .table{margin-top:10px;}
  1089. </style>