59feca36d0b9005f6794bf11ea6c456eb23403b1.svn-base 55 KB

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