96532f9ecadfeead8015625d757e5c0ee8325a43.svn-base 55 KB

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