63647f972bee33b5de1ebce85ed93c80605cbc03.svn-base 55 KB

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