edb1a4bf95d90e2e635716e7129ae47fae71e730.svn-base 45 KB

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