21fe6f7d7981aaa343e5ab2f831009e7faeee1f1.svn-base 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  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.startTime = 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.startTime = ''
  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. const barid = new RegExp("key 'barid'")
  531. if (barid.test(response.data)) {
  532. this.$message({ type: 'error', message: '该栏舍今日生产性能已存在,不可重复生成', duration: 2000 })
  533. } else {
  534. failproccess(response, this.$notify)
  535. }
  536. if (this.create.temp.cowsum == '0') { this.create.temp.cowsum = '' }
  537. if (this.create.temp.tem == '0') { this.create.temp.tem = '' }
  538. if (this.create.temp.avgmonthage == '0') { this.create.temp.avgmonthage = '' }
  539. if (this.create.temp.bw == '0') { this.create.temp.bw = '' }
  540. if (this.create.temp.dayw == '0') { this.create.temp.dayw = '' }
  541. if (this.create.temp.dayspre == '0') { this.create.temp.dayspre = '' }
  542. if (this.create.temp.fetal == '0') { this.create.temp.fetal = '' }
  543. if (this.create.temp.avgdim == '0') { this.create.temp.avgdim = '' }
  544. if (this.create.temp.product == '0') { this.create.temp.product = '' }
  545. if (this.create.temp.fat == '0') { this.create.temp.fat = '' }
  546. if (this.create.temp.pro == '0') { this.create.temp.pro = '' }
  547. if (this.create.temp.lactose == '0') { this.create.temp.lactose = '' }
  548. }
  549. })
  550. }
  551. })
  552. },
  553. createDataAgain() {
  554. console.log('点击了新增保存')
  555. this.isokDisable = true
  556. setTimeout(() => {
  557. this.isokDisable = false
  558. }, 1000)
  559. this.$refs['temp'].validate(valid => {
  560. if (valid) {
  561. this.isokDisable = true
  562. setTimeout(() => {
  563. this.isokDisable = false
  564. }, 1000)
  565. const positiveInteger = /^[1-9]\d*$/
  566. // 牛头数
  567. if (this.create.temp.cowsum !== '') {
  568. if (!positiveInteger.test(parseFloat(this.create.temp.cowsum))) {
  569. this.$message({ type: 'error', message: '牛头数请输入正整数', duration: 2000 })
  570. return false
  571. }
  572. }
  573. const twoDecimalPlaces = /^\d+(\.\d{1,2})?$/
  574. // 温度环境
  575. if (this.create.temp.tem !== '') {
  576. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.tem))) {
  577. this.$message({ type: 'error', message: '温度环境请保留两位小数', duration: 2000 })
  578. return false
  579. }
  580. }
  581. // 平均月龄
  582. if (this.create.temp.avgmonthage !== '') {
  583. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.avgmonthage))) {
  584. this.$message({ type: 'error', message: '平均月龄请保留两位小数', duration: 2000 })
  585. return false
  586. }
  587. }
  588. // 体重
  589. if (this.create.temp.bw !== '') {
  590. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.bw))) {
  591. this.$message({ type: 'error', message: '体重请保留两位小数', duration: 2000 })
  592. return false
  593. }
  594. }
  595. // 日增重
  596. if (this.create.temp.dayw !== '') {
  597. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.dayw))) {
  598. this.$message({ type: 'error', message: '日增重请保留两位小数', duration: 2000 })
  599. return false
  600. }
  601. }
  602. const dayspre = /^(([1-9]|([1-9]\d)|(1\d\d)|(2([0-7]\d|7[0-9]))))$/
  603. // 怀孕天数
  604. if (this.create.temp.dayspre !== '') {
  605. if (!dayspre.test(parseFloat(this.create.temp.dayspre))) {
  606. this.$message({ type: 'error', message: '怀孕天数请输入大于0小于280正整数', duration: 2000 })
  607. return false
  608. }
  609. }
  610. const fetal = /^(?:[1-9]|1[0-9])$/
  611. // 胎次
  612. if (this.create.temp.fetal !== '') {
  613. if (!fetal.test(parseFloat(this.create.temp.fetal))) {
  614. this.$message({ type: 'error', message: '胎次请输入大于0小于20正整数', duration: 2000 })
  615. return false
  616. }
  617. }
  618. // 平均泌乳
  619. if (this.create.temp.avgdim !== '') {
  620. if (!positiveInteger.test(parseFloat(this.create.temp.avgdim))) {
  621. this.$message({ type: 'error', message: '平均泌乳天数请输入正整数', duration: 2000 })
  622. return false
  623. }
  624. }
  625. // 产奶量
  626. if (this.create.temp.product !== '') {
  627. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.product))) {
  628. this.$message({ type: 'error', message: '产奶量请保留两位小数', duration: 2000 })
  629. return false
  630. }
  631. }
  632. // 乳脂率
  633. if (this.create.temp.fat !== '') {
  634. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.fat))) {
  635. this.$message({ type: 'error', message: '乳脂率请保留两位小数', duration: 2000 })
  636. return false
  637. }
  638. }
  639. // 乳蛋白率
  640. if (this.create.temp.pro !== '') {
  641. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.pro))) {
  642. this.$message({ type: 'error', message: '乳蛋白率请保留两位小数', duration: 2000 })
  643. return false
  644. }
  645. }
  646. // 乳糖率
  647. if (this.create.temp.lactose !== '') {
  648. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.lactose))) {
  649. this.$message({ type: 'error', message: '乳糖率请保留两位小数', duration: 2000 })
  650. return false
  651. }
  652. }
  653. this.requestParam.name = 'insertBarmilk'
  654. this.requestParam.parammaps = this.create.temp
  655. if (this.create.temp.cowsum == '') { this.create.temp.cowsum = '0' }
  656. if (this.create.temp.tem == '') { this.create.temp.tem = '0' }
  657. if (this.create.temp.avgmonthage == '') { this.create.temp.avgmonthage = '0' }
  658. if (this.create.temp.bw == '') { this.create.temp.bw = '0' }
  659. if (this.create.temp.dayw == '') { this.create.temp.dayw = '0' }
  660. if (this.create.temp.dayspre == '') { this.create.temp.dayspre = '0' }
  661. if (this.create.temp.fetal == '') { this.create.temp.fetal = '0' }
  662. if (this.create.temp.avgdim == '') { this.create.temp.avgdim = '0' }
  663. if (this.create.temp.product == '') { this.create.temp.product = '0' }
  664. if (this.create.temp.fat == '') { this.create.temp.fat = '0' }
  665. if (this.create.temp.pro == '') { this.create.temp.pro = '0' }
  666. if (this.create.temp.lactose == '') { this.create.temp.lactose = '0' }
  667. PostDataByName(this.requestParam).then(response => {
  668. console.log('新增保存发送参数', this.requestParam)
  669. if (response.msg !== 'fail') {
  670. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  671. this.resetTemp()
  672. this.create.noteTakerList = []
  673. this.getNoteTakerList()
  674. } else {
  675. const barid = new RegExp("key 'barid'")
  676. if (barid.test(response.data)) {
  677. this.$message({ type: 'error', message: '该栏舍今日生产性能已存在,不可重复生成', duration: 2000 })
  678. } else {
  679. failproccess(response, this.$notify)
  680. }
  681. if (this.create.temp.cowsum == '0') { this.create.temp.cowsum = '' }
  682. if (this.create.temp.tem == '0') { this.create.temp.tem = '' }
  683. if (this.create.temp.avgmonthage == '0') { this.create.temp.avgmonthage = '' }
  684. if (this.create.temp.bw == '0') { this.create.temp.bw = '' }
  685. if (this.create.temp.dayw == '0') { this.create.temp.dayw = '' }
  686. if (this.create.temp.dayspre == '0') { this.create.temp.dayspre = '' }
  687. if (this.create.temp.fetal == '0') { this.create.temp.fetal = '' }
  688. if (this.create.temp.avgdim == '0') { this.create.temp.avgdim = '' }
  689. if (this.create.temp.product == '0') { this.create.temp.product = '' }
  690. if (this.create.temp.fat == '0') { this.create.temp.fat = '' }
  691. if (this.create.temp.pro == '0') { this.create.temp.pro = '' }
  692. if (this.create.temp.lactose == '0') { this.create.temp.lactose = '' }
  693. }
  694. })
  695. }
  696. })
  697. },
  698. // 编辑
  699. handleUpdate(row) {
  700. console.log('点击了编辑', row)
  701. row.barid = String(row.barid)
  702. row.cowclassid = String(row.cowclassid)
  703. this.create.temp = Object.assign({}, row)
  704. this.create.temp.id = row.id
  705. if (this.create.temp.dayspre == '0') { this.create.temp.dayspre = '' }
  706. if (this.create.temp.fetal == '0') { this.create.temp.fetal = '' }
  707. if (this.create.temp.cowsum == '0') { this.create.temp.cowsum = '' }
  708. if (this.create.temp.avgdim == '0') { this.create.temp.avgdim = '' }
  709. this.getNoteTakerList()
  710. this.create.dialogStatus = 'update'
  711. this.create.dialogFormVisible = true
  712. },
  713. updateData() {
  714. this.isokDisable = true
  715. setTimeout(() => {
  716. this.isokDisable = false
  717. }, 1000)
  718. this.$refs['temp'].validate(valid => {
  719. if (valid) {
  720. this.isokDisable = true
  721. setTimeout(() => {
  722. this.isokDisable = false
  723. }, 1000)
  724. const positiveInteger = /^[1-9]\d*$/
  725. // 牛头数
  726. if (this.create.temp.cowsum !== '') {
  727. if (!positiveInteger.test(parseFloat(this.create.temp.cowsum))) {
  728. this.$message({ type: 'error', message: '牛头数请输入正整数', duration: 2000 })
  729. return false
  730. }
  731. }
  732. const twoDecimalPlaces = /^\d+(\.\d{1,2})?$/
  733. // 温度环境
  734. if (this.create.temp.tem !== '') {
  735. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.tem))) {
  736. this.$message({ type: 'error', message: '温度环境请保留两位小数', duration: 2000 })
  737. return false
  738. }
  739. }
  740. // 平均月龄
  741. if (this.create.temp.avgmonthage !== '') {
  742. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.avgmonthage))) {
  743. this.$message({ type: 'error', message: '平均月龄请保留两位小数', duration: 2000 })
  744. return false
  745. }
  746. }
  747. // 体重
  748. if (this.create.temp.bw !== '') {
  749. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.bw))) {
  750. this.$message({ type: 'error', message: '体重请保留两位小数', duration: 2000 })
  751. return false
  752. }
  753. }
  754. // 日增重
  755. if (this.create.temp.dayw !== '') {
  756. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.dayw))) {
  757. this.$message({ type: 'error', message: '日增重请保留两位小数', duration: 2000 })
  758. return false
  759. }
  760. }
  761. const dayspre = /^(([1-9]|([1-9]\d)|(1\d\d)|(2([0-7]\d|7[0-9]))))$/
  762. // 怀孕天数
  763. if (this.create.temp.dayspre !== '') {
  764. if (!dayspre.test(parseFloat(this.create.temp.dayspre))) {
  765. this.$message({ type: 'error', message: '怀孕天数请输入大于0小于280正整数', duration: 2000 })
  766. return false
  767. }
  768. }
  769. const fetal = /^(?:[1-9]|1[0-9])$/
  770. // 胎次
  771. if (this.create.temp.fetal !== '') {
  772. if (!fetal.test(parseFloat(this.create.temp.fetal))) {
  773. this.$message({ type: 'error', message: '胎次请输入大于0小于20正整数', duration: 2000 })
  774. return false
  775. }
  776. }
  777. // 平均泌乳
  778. if (this.create.temp.avgdim !== '') {
  779. if (!positiveInteger.test(parseFloat(this.create.temp.avgdim))) {
  780. this.$message({ type: 'error', message: '平均泌乳天数请输入正整数', duration: 2000 })
  781. return false
  782. }
  783. }
  784. // 产奶量
  785. if (this.create.temp.product !== '') {
  786. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.product))) {
  787. this.$message({ type: 'error', message: '产奶量请保留两位小数', duration: 2000 })
  788. return false
  789. }
  790. }
  791. // 乳脂率
  792. if (this.create.temp.fat !== '') {
  793. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.fat))) {
  794. this.$message({ type: 'error', message: '乳脂率请保留两位小数', duration: 2000 })
  795. return false
  796. }
  797. }
  798. // 乳蛋白率
  799. if (this.create.temp.pro !== '') {
  800. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.pro))) {
  801. this.$message({ type: 'error', message: '乳蛋白率请保留两位小数', duration: 2000 })
  802. return false
  803. }
  804. }
  805. // 乳糖率
  806. if (this.create.temp.lactose !== '') {
  807. if (!twoDecimalPlaces.test(parseFloat(this.create.temp.lactose))) {
  808. this.$message({ type: 'error', message: '乳糖率请保留两位小数', duration: 2000 })
  809. return false
  810. }
  811. }
  812. this.requestParam.name = 'updateBarmilk'
  813. this.requestParam.parammaps = this.create.temp
  814. if (this.create.temp.cowsum == '') { this.create.temp.cowsum = '0' }
  815. if (this.create.temp.tem == '') { this.create.temp.tem = '0' }
  816. if (this.create.temp.avgmonthage == '') { this.create.temp.avgmonthage = '0' }
  817. if (this.create.temp.bw == '') { this.create.temp.bw = '0' }
  818. if (this.create.temp.dayw == '') { this.create.temp.dayw = '0' }
  819. if (this.create.temp.dayspre == '') { this.create.temp.dayspre = '0' }
  820. if (this.create.temp.fetal == '') { this.create.temp.fetal = '0' }
  821. if (this.create.temp.avgdim == '') { this.create.temp.avgdim = '0' }
  822. if (this.create.temp.product == '') { this.create.temp.product = '0' }
  823. if (this.create.temp.fat == '') { this.create.temp.fat = '0' }
  824. if (this.create.temp.pro == '') { this.create.temp.pro = '0' }
  825. if (this.create.temp.lactose == '') { this.create.temp.lactose = '0' }
  826. PostDataByName(this.requestParam).then(response => {
  827. console.log('新增保存发送参数', this.requestParam)
  828. if (response.msg !== 'fail') {
  829. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  830. this.create.dialogFormVisible = false
  831. this.getList()
  832. } else {
  833. failproccess(response, this.$notify)
  834. if (this.create.temp.dayspre == '0') { this.create.temp.dayspre = '' }
  835. if (this.create.temp.fetal == '0') { this.create.temp.fetal = '' }
  836. if (this.create.temp.cowsum == '0') { this.create.temp.cowsum = '' }
  837. if (this.create.temp.avgdim == '0') { this.create.temp.avgdim = '' }
  838. }
  839. })
  840. }
  841. })
  842. },
  843. // 删除
  844. handleRowDelete(row) {
  845. console.log('点击了行内删除')
  846. MessageBox.confirm('是否确认删除此信息?', {
  847. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  848. }).then(() => {
  849. this.selectList = []
  850. this.requestParam.name = 'deleteBarmilk'
  851. this.requestParam.parammaps = {}
  852. this.requestParam.parammaps.pastureid = row.pastureid
  853. this.requestParam.parammaps.id = row.id
  854. PostDataByName(this.requestParam).then(response => {
  855. if (response.msg === 'fail') {
  856. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  857. } else {
  858. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  859. this.getList()
  860. }
  861. })
  862. }).catch(() => {
  863. this.$message({ type: 'info', message: '已取消删除' })
  864. })
  865. },
  866. handleSelectionChange(val) {
  867. console.log('勾选数据', val)
  868. this.selectList = val
  869. },
  870. handleDelete() {
  871. console.log('点击了删除')
  872. if (this.selectList.length == 0) {
  873. this.$message({ type: 'error', message: '请选择栏舍生产性能', duration: 2000 })
  874. } else {
  875. MessageBox.confirm('是否确认删除此信息?', {
  876. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  877. }).then(() => {
  878. console.log(this.selectList)
  879. this.requestParam.common = { 'returnmap': '0' }
  880. this.requestParam.data = []
  881. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  882. this.requestParam.data[0].children = []
  883. this.requestParam.data[0].children[0] = { 'name': 'deleteBarmilk', 'type': 'e', 'parammaps': {
  884. id: '@insertSpotList.id',
  885. pastureid: '@insertSpotList.pastureid'
  886. }}
  887. ExecDataByConfig(this.requestParam).then(response => {
  888. console.log('删除保存发送参数', this.requestParam)
  889. if (response.msg === 'fail') {
  890. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  891. } else {
  892. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  893. this.getList()
  894. }
  895. })
  896. })
  897. }
  898. },
  899. // 复制
  900. handleCopy() {
  901. console.log('点击了复制')
  902. if (this.selectList.length == 0) {
  903. this.$message({ type: 'error', message: '请选择栏舍生产性能', duration: 2000 })
  904. } else if (this.selectList.length == 1) {
  905. MessageBox.confirm('是否确认复制此信息?', {
  906. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  907. }).then(() => {
  908. this.requestParam.name = 'copybarmilk'
  909. this.requestParam.parammaps = {}
  910. this.requestParam.parammaps.pastureid = this.selectList[0].pastureid
  911. this.requestParam.parammaps.id = this.selectList[0].id
  912. PostDataByName(this.requestParam).then(response => {
  913. if (response.msg === 'fail') {
  914. const barid = new RegExp("key 'barid'")
  915. if (barid.test(response.data)) {
  916. this.$message({ type: 'error', message: '该栏舍今日生产性能已存在,不可重复生成', duration: 2000 })
  917. } else {
  918. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  919. }
  920. } else {
  921. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  922. this.getList()
  923. }
  924. })
  925. }).catch(() => {
  926. this.$message({ type: 'info', message: '已取消删除' })
  927. })
  928. } else {
  929. this.$message({ type: 'error', message: '请选择一条栏舍生产性能', duration: 2000 })
  930. }
  931. },
  932. // 导出
  933. handleExport() {
  934. console.log('点击了导出')
  935. },
  936. // 导入
  937. handleImport() {
  938. console.log('点击了导入')
  939. }
  940. }
  941. }
  942. </script>
  943. <style lang="scss" scoped>
  944. .search{padding-top:10px;clear: both;}
  945. .table{margin-top:10px;}
  946. </style>