2c1b6d3f15f6e9e2ef25d3eccdf51c0b8cc19166.svn-base 53 KB

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