bddb302ff2adbf0299824357e6be4d008d7d25af.svn-base 43 KB

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