5c6c332e83d8b8c2c098f78ac821456a98f786aa.svn-base 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  5. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  6. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  7. <el-select v-model="table.getdataListParm.parammaps.barid" filterable placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  8. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  9. </el-select>
  10. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  11. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  12. </div>
  13. <div class="operation">
  14. <el-button v-if="isRoleEdit" icon="el-icon-plus" class="success" style="float: left;margin-right:10px;" @click="handleCreate">新增</el-button>
  15. <el-button v-if="isRoleEdit" icon="el-icon-delete" class="danger" style="float: left;margin-right:10px;" @click="handleDelete">删除</el-button>
  16. <el-button v-if="isRoleEdit" icon="el-icon-copy-document" class="copy" style="float: left;margin-right:10px;" @click="handleCopy">复制</el-button>
  17. <el-upload v-if="isRoleEdit" style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  18. <el-button class="import" icon="el-icon-download" style="float: right;">导入</el-button>
  19. </el-upload>
  20. <el-dropdown style="float: right;margin-right: 10px;">
  21. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  22. <el-dropdown-menu slot="dropdown">
  23. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  24. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  25. </el-dropdown-menu>
  26. </el-dropdown>
  27. <el-button class="export" style="float: right;" @click="handleHistoryRecord">历史记录</el-button>
  28. </div>
  29. <div class="table">
  30. <el-table
  31. :key="table.tableKey"
  32. v-loading="table.listLoading"
  33. element-loading-text="给我一点时间"
  34. :data="table.list"
  35. border
  36. fit
  37. highlight-current-row
  38. style="width: 100%;"
  39. :row-style="rowStyle"
  40. :cell-style="cellStyle"
  41. class="elTable table-fixed"
  42. @selection-change="handleSelectionChange"
  43. >
  44. <el-table-column type="selection" align="center" width="50" />
  45. <el-table-column label="序号" align="center" type="index" width="50px">
  46. <template slot-scope="scope">
  47. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="栏舍名称" min-width="100px" align="center">
  51. <template slot-scope="scope">
  52. <span>{{ scope.row.barname }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="标准分数(分)" min-width="65x" align="center">
  56. <template slot-scope="scope">
  57. <span>{{ scope.row.standardscore }}</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="牛头数(头)" min-width="65x" align="center">
  61. <template slot-scope="scope">
  62. <span>{{ scope.row.cowsum }}</span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="评分" align="center">
  66. <el-table-column label="2.75分-(头)" min-width="65px" align="center">
  67. <template slot-scope="scope">
  68. <span>{{ scope.row.score25 }}({{ scope.row.score25rate }}%)</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="2.75分(头)" min-width="65px" align="center">
  72. <template slot-scope="scope">
  73. <span>{{ scope.row.score275 }}({{ scope.row.score275rate }}%)</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="3分(头)" min-width="65px" align="center">
  77. <template slot-scope="scope">
  78. <span>{{ scope.row.score3 }}({{ scope.row.score3rate }}%)</span>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="3.25分(头)" min-width="65px" align="center">
  82. <template slot-scope="scope">
  83. <span>{{ scope.row.score325 }}({{ scope.row.score325rate }}%)</span>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="3.5分(头)" min-width="65px" align="center">
  87. <template slot-scope="scope">
  88. <span>{{ scope.row.score35 }}({{ scope.row.score35rate }}%)</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="3.75分(头)" min-width="65px" align="center">
  92. <template slot-scope="scope">
  93. <span>{{ scope.row.score375 }}({{ scope.row.score375rate }}%)</span>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="4分+(头)" min-width="65px" align="center">
  97. <template slot-scope="scope">
  98. <span>{{ scope.row.score4 }}({{ scope.row.score4rate }}%)</span>
  99. </template>
  100. </el-table-column>
  101. </el-table-column>
  102. <el-table-column label="备注" min-width="90px" align="center">
  103. <template slot-scope="scope">
  104. <span>{{ scope.row.remark }}</span>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="操作人" min-width="90px" align="center">
  108. <template slot-scope="scope">
  109. <span>{{ scope.row.emp }}</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.operatetime }}</span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  118. <template slot-scope="{row}">
  119. <el-button v-if="isRoleEdit" icon="el-icon-edit-outline" class="miniSuccess" @click="handleUpdate(row)" />
  120. <span v-if="isRoleEdit" class="centerSpan">|</span>
  121. <el-button v-if="isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  126. </div>
  127. <!-- 新增/编辑 -->
  128. <el-dialog :fullscreen="dialogFull" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  129. <template slot="title">
  130. <div class="avue-crud__dialog__header">
  131. <span class="el-dialog__title">
  132. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  133. {{ textMap[create.dialogStatus] }}
  134. </span>
  135. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  136. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  137. <svg-icon v-else icon-class="fullscreen" />
  138. </div>
  139. </div>
  140. </template>
  141. <div class="app-add">
  142. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="150px" style="width: 100%;margin:0 auto 50px">
  143. <el-row>
  144. <el-col :span="24">
  145. <h3 style="width: 150px;text-align: right;">栏舍信息</h3>
  146. </el-col>
  147. </el-row>
  148. <el-row>
  149. <el-col v-if="create.dialogStatus=='create'" :span="6">
  150. <el-form-item label="栏舍名称:" prop="barid">
  151. <el-select ref="barid" v-model="create.temp.barid" :disabled="create.dialogStatus == 'update'" filterable placeholder="栏舍名称" class="filter-item" style="width: 100%;" @change="changeBar">
  152. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  153. </el-select>
  154. </el-form-item>
  155. </el-col>
  156. <el-col v-else :span="6">
  157. <el-form-item label="栏舍名称:" prop="barname">
  158. <el-input ref="barname" v-model="create.temp.barname" disabled class="filter-item" placeholder="barname" />
  159. </el-form-item>
  160. </el-col>
  161. </el-row>
  162. <el-row>
  163. <el-col :span="24">
  164. <h3 style="width: 150px;text-align: right;">评分</h3>
  165. </el-col>
  166. </el-row>
  167. <el-row>
  168. <el-col :span="6">
  169. <el-form-item label="标准分数(分):" prop="standardscore">
  170. <el-input ref="standardscore" v-model="create.temp.standardscore" class="filter-item" style="width: 100%;" disabled />
  171. </el-form-item>
  172. </el-col>
  173. <el-col :span="6">
  174. <el-form-item label="牛头数(头):" prop="cowsum">
  175. <el-input ref="cowsum" v-model="create.temp.cowsum" class="filter-item" style="width: 100%;" disabled />
  176. </el-form-item>
  177. </el-col>
  178. </el-row>
  179. <el-row>
  180. <el-col :span="6">
  181. <el-form-item label="2.75分-:" prop="score25">
  182. <el-input ref="score25" v-model="create.temp.score25" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  183. </el-form-item>
  184. </el-col>
  185. <el-col :span="6">
  186. <el-form-item label="2.75分:" prop="score275">
  187. <el-input ref="score275" v-model="create.temp.score275" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  188. </el-form-item>
  189. </el-col>
  190. <el-col :span="6">
  191. <el-form-item label="3分:" prop="score3">
  192. <el-input ref="score3" v-model="create.temp.score3" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  193. </el-form-item>
  194. </el-col>
  195. <el-col :span="6">
  196. <el-form-item label="3.25分:" prop="score325">
  197. <el-input ref="score325" v-model="create.temp.score325" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  198. </el-form-item>
  199. </el-col>
  200. </el-row>
  201. <el-row>
  202. <el-col :span="6">
  203. <el-form-item label="3.5分:" prop="score35">
  204. <el-input ref="score35" v-model="create.temp.score35" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  205. </el-form-item>
  206. </el-col>
  207. <el-col :span="6">
  208. <el-form-item label="3.75分:" prop="score375">
  209. <el-input ref="score375" v-model="create.temp.score375" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  210. </el-form-item>
  211. </el-col>
  212. <el-col :span="6">
  213. <el-form-item label="4分+:" prop="score4">
  214. <el-input ref="score4" v-model="create.temp.score4" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  215. </el-form-item>
  216. </el-col>
  217. </el-row>
  218. <el-row>
  219. <el-col :span="24">
  220. <h3 style="width: 150px;text-align: right;">操作详情</h3>
  221. </el-col>
  222. </el-row>
  223. <el-row>
  224. <el-col :span="6">
  225. <el-form-item label="操作人:" prop="emp">
  226. <el-select ref="emp" v-model="create.temp.emp" filterable placeholder="操作人" class="filter-item" style="width: 100%;" @blur="blurEmp">
  227. <el-option v-for="item in create.noteTakerList" :key="item.myId" :label="item.emp" :value="item.emp" />
  228. </el-select>
  229. </el-form-item>
  230. </el-col>
  231. <el-col :span="6">
  232. <el-form-item label="操作日期:" prop="operatetime">
  233. <el-date-picker v-model="create.temp.operatetime" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 100%;" :clearable="false" @change="changeOperatetime" />
  234. </el-form-item>
  235. </el-col>
  236. <el-col :span="12">
  237. <el-form-item label="备注:" prop="remark">
  238. <el-input ref="remark" v-model="create.temp.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" placeholder="1-255字符" maxlength="255" class="filter-item" style="width: 100%;" />
  239. </el-form-item>
  240. </el-col>
  241. </el-row>
  242. </el-form>
  243. <div slot="footer" class="dialog-footer">
  244. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  245. <el-button v-if="create.dialogStatus==='create'" class="save" :disabled="isokDisable" @click="createDataAgain()">确认新增</el-button>
  246. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="save" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  247. </div>
  248. </div>
  249. </el-dialog>
  250. <!-- 历史记录 -->
  251. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  252. <template slot="title">
  253. <div class="avue-crud__dialog__header">
  254. <span class="el-dialog__title">
  255. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  256. {{ textMap[historyRecord.dialogStatus] }}
  257. </span>
  258. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  259. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  260. <svg-icon v-else icon-class="fullscreen" />
  261. </div>
  262. </div>
  263. </template>
  264. <div class="historyRecord">
  265. <keep-alive>
  266. <component :is="historyRecord.myComponent" ref="historyRecord" />
  267. </keep-alive>
  268. </div>
  269. <div slot="footer" class="dialog-footer">
  270. <el-button class="cancelClose cancelClose1" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  271. </div>
  272. </el-dialog>
  273. </div>
  274. </template>
  275. <script>
  276. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  277. import Cookies from 'js-cookie'
  278. import { parseTime, json2excel } from '@/utils/index.js'
  279. import Pagination from '@/components/Pagination'
  280. import { MessageBox } from 'element-ui'
  281. import axios from 'axios'
  282. import { getToken } from '@/utils/auth'
  283. export default {
  284. name: 'PhysicalConditionScore',
  285. components: { Pagination },
  286. data() {
  287. return {
  288. dialogFull: false,
  289. isRoleEdit: [],
  290. requestParams: [
  291. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }},
  292. { name: 'getSysoptEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid'), 'inforname': 'times' }}
  293. ],
  294. houseNameList: [], // 栏舍名称
  295. frequencyList: [], // 班次
  296. table: {
  297. getdataListParm: {
  298. name: 'getBodyscoreList',
  299. page: 1,
  300. offset: 1,
  301. pagecount: parseInt(Cookies.get('pageCount')),
  302. returntype: 'Map',
  303. parammaps: {
  304. pastureid: Cookies.get('pastureid'),
  305. barid: '',
  306. times: '',
  307. startTime: '',
  308. stopTime: '',
  309. inputDatetime: ''
  310. }
  311. },
  312. tableKey: 0,
  313. list: [],
  314. total: 0,
  315. listLoading: true,
  316. temp: {}
  317. },
  318. // 新增/编辑
  319. create: {
  320. dialogFormVisible: false,
  321. dialogStatus: '',
  322. temp: { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d}'), emp: Cookies.get('employename'), barid: '', barname: '', times: '', standardscore: '', cowsum: '', score25: '', score275: '', score3: '', score325: '', score35: '', score375: '', score4: '', remark: '', ftid: '', ftname: '' },
  323. rules: {
  324. barid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  325. times: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  326. score25: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  327. score275: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  328. score3: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  329. score325: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  330. score35: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  331. score375: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  332. score4: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  333. },
  334. // 操作人
  335. getdataListParm: {
  336. name: 'getBodyscoreEmpHis',
  337. page: 1,
  338. offset: 1,
  339. pagecount: 10,
  340. returntype: 'Map',
  341. parammaps: {
  342. pastureid: Cookies.get('pastureid')
  343. }
  344. },
  345. // 体况评分参数
  346. getdataListParm2: {
  347. name: 'getDungAndBodyScore',
  348. page: 1,
  349. offset: 1,
  350. pagecount: 1,
  351. returntype: 'Map',
  352. parammaps: {
  353. pastureid: Cookies.get('pastureid'),
  354. barid: '',
  355. date: ''
  356. }
  357. },
  358. noteTakerList: [] // 记录人
  359. },
  360. textMap: {
  361. create: '新增',
  362. update: '编辑',
  363. historyRecord: '历史记录'
  364. },
  365. historyRecord: {
  366. dialogFormVisible: false,
  367. dialogStatus: '',
  368. myComponent: null
  369. },
  370. requestParam: {},
  371. requestParam2: {},
  372. download: {
  373. getdataListParm: {
  374. name: 'getBodyscoreList',
  375. page: 1,
  376. offset: 1,
  377. pagecount: 0,
  378. returntype: 'Map',
  379. parammaps: {
  380. pastureid: Cookies.get('pastureid'),
  381. barid: '',
  382. times: '',
  383. startTime: '',
  384. stopTime: '',
  385. inputDatetime: ''
  386. }
  387. },
  388. list: []
  389. },
  390. isokDisable: false,
  391. selectList: [],
  392. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  393. cellStyle: { padding: 0 + 'px' }
  394. }
  395. },
  396. computed: {
  397. // 设置请求头
  398. headers() {
  399. return {
  400. token: getToken()
  401. }
  402. },
  403. uploadData() {
  404. return {
  405. name: 'checkbarname,insertBodyscoreUpload',
  406. importParams: '栏舍名称,2.75-分(头),2.75分(头),3分(头),3.25分(头),3.5分(头),3.75分(头),4+分(头),备注,操作人,操作日期',
  407. sheetname: 'Sheet1',
  408. // 登录牧场
  409. pastureid: Cookies.get('pastureid'),
  410. // 日期参数
  411. dateParams: '操作日期',
  412. // 必填参数
  413. requiredParams: '栏舍名称,2.75-分(头),2.75分(头),3分(头),3.25分(头),3.5分(头),3.75分(头),4+分(头)',
  414. // 为数值的参数
  415. numParams: '2.75-分(头),2.75分(头),3分(头),3.25分(头),3.5分(头),3.75分(头),4+分(头)'
  416. }
  417. },
  418. // 设置上传地址
  419. uploadExcelUrl() {
  420. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  421. }
  422. },
  423. created() {
  424. this.getButtons()
  425. this.getList()
  426. this.getDownList()
  427. },
  428. methods: {
  429. getButtons() {
  430. const Edit = 'PhysicalConditionScore'
  431. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  432. this.isRoleEdit = isRoleEdit
  433. },
  434. getDownList() {
  435. GetDataByNames(this.requestParams).then(response => {
  436. this.houseNameList = response.data.getBarListEnable.list
  437. if (response.data.getSysoptEnable.list !== null) {
  438. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  439. const obj = {}
  440. obj.id = String(i)
  441. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  442. this.frequencyList.push(obj)
  443. }
  444. } else {
  445. this.frequencyList = []
  446. }
  447. })
  448. },
  449. handleBefore() {
  450. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  451. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  452. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  453. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  454. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  455. this.$forceUpdate()
  456. }
  457. },
  458. handleNext() {
  459. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  460. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  461. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  462. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  463. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  464. this.$forceUpdate()
  465. }
  466. },
  467. getList() {
  468. this.table.listLoading = true
  469. GetDataByName(this.table.getdataListParm).then(response => {
  470. console.log('table数据', response.data.list)
  471. if (response.data.list !== null) {
  472. for (let i = 0; i < response.data.list.length; i++) {
  473. this.$set(response.data.list[i], 'score25rate', (parseFloat(response.data.list[i].score25) / parseFloat(response.data.list[i].cowsum) * 100).toFixed(2))
  474. this.$set(response.data.list[i], 'score275rate', (parseFloat(response.data.list[i].score275) / parseFloat(response.data.list[i].cowsum) * 100).toFixed(2))
  475. this.$set(response.data.list[i], 'score3rate', (parseFloat(response.data.list[i].score3) / parseFloat(response.data.list[i].cowsum) * 100).toFixed(2))
  476. this.$set(response.data.list[i], 'score325rate', (parseFloat(response.data.list[i].score325) / parseFloat(response.data.list[i].cowsum) * 100).toFixed(2))
  477. this.$set(response.data.list[i], 'score35rate', (parseFloat(response.data.list[i].score35) / parseFloat(response.data.list[i].cowsum) * 100).toFixed(2))
  478. this.$set(response.data.list[i], 'score375rate', (parseFloat(response.data.list[i].score375) / parseFloat(response.data.list[i].cowsum) * 100).toFixed(2))
  479. this.$set(response.data.list[i], 'score4rate', (100 - response.data.list[i].score25rate - response.data.list[i].score275rate - response.data.list[i].score3rate - response.data.list[i].score325rate - response.data.list[i].score35rate - response.data.list[i].score375rate).toFixed(2))
  480. }
  481. this.table.list = response.data.list
  482. this.table.pageNum = response.data.pageNum
  483. this.table.pageSize = response.data.pageSize
  484. this.table.total = response.data.total
  485. } else {
  486. this.table.list = []
  487. }
  488. setTimeout(() => {
  489. this.table.listLoading = false
  490. }, 100)
  491. })
  492. },
  493. handleSearch() {
  494. console.log('点击了查询')
  495. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  496. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  497. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  498. } else {
  499. this.table.getdataListParm.parammaps.inputDatetime = ''
  500. this.table.getdataListParm.parammaps.startTime = ''
  501. this.table.getdataListParm.parammaps.stopTime = ''
  502. }
  503. this.table.getdataListParm.offset = 1
  504. this.getList()
  505. },
  506. handleRefresh() {
  507. console.log('点击了重置')
  508. this.table.getdataListParm.parammaps.barid = ''
  509. this.table.getdataListParm.parammaps.times = ''
  510. this.table.getdataListParm.parammaps.startTime = ''
  511. this.table.getdataListParm.parammaps.stopTime = ''
  512. this.table.getdataListParm.parammaps.inputDatetime = ''
  513. this.table.getdataListParm.offset = 1
  514. this.getList()
  515. },
  516. // 新增
  517. resetTemp() {
  518. this.create.temp = { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d}'), emp: Cookies.get('employename'), barid: '', barname: '', times: '', standardscore: '', cowsum: '', score25: '', score275: '', score3: '', score325: '', score35: '', score375: '', score4: '', remark: '', ftid: '', ftname: '' }
  519. },
  520. blurEmp(item) {
  521. this.create.temp.emp = item.target.value
  522. },
  523. // 栏舍名称
  524. changeBar(item) {
  525. this.create.temp.barname = this.houseNameList.find(obj => obj.id === item).bname
  526. this.getRange()
  527. },
  528. changeOperatetime() {
  529. this.getRange()
  530. },
  531. // 粪便评分参数
  532. getRange() {
  533. this.create.getdataListParm2.parammaps.date = this.create.temp.operatetime
  534. this.create.getdataListParm2.parammaps.barid = this.create.temp.barid
  535. GetDataByName(this.create.getdataListParm2).then(response => {
  536. if (response.data.list !== null) {
  537. this.create.temp.standardscore = response.data.list[0].bodystandard
  538. this.create.temp.ftid = response.data.list[0].ftid
  539. this.create.temp.ftname = response.data.list[0].ftname
  540. } else {
  541. this.create.temp.standardscore = ''
  542. this.create.temp.ftid = ''
  543. this.create.temp.ftname = ''
  544. }
  545. })
  546. },
  547. // 操作人
  548. getNoteTakerList() {
  549. GetDataByName(this.create.getdataListParm).then(response => {
  550. if (response.data.list !== null) {
  551. for (let i = 0; i < response.data.list.length; i++) {
  552. response.data.list[i].myId = i
  553. }
  554. this.create.noteTakerList = response.data.list
  555. console.log('记录人数据', response.data.list)
  556. console.log(this.create.noteTakerList)
  557. } else {
  558. this.create.noteTakerList = []
  559. }
  560. })
  561. },
  562. blurScore() {
  563. if (this.create.temp.score25 !== '' && this.create.temp.score275 !== '' && this.create.temp.score3 !== '' && this.create.temp.score325 !== '' && this.create.temp.score35 !== '' && this.create.temp.score375 !== '' && this.create.temp.score4 !== '') {
  564. this.create.temp.cowsum = parseInt(this.create.temp.score25) + parseInt(this.create.temp.score275) + parseInt(this.create.temp.score3) + parseInt(this.create.temp.score325) + parseInt(this.create.temp.score35) + parseInt(this.create.temp.score375) + parseInt(this.create.temp.score4)
  565. }
  566. },
  567. handleCreate() {
  568. console.log('点击了新增')
  569. this.resetTemp()
  570. this.getNoteTakerList()
  571. this.dialogFull = false
  572. this.create.dialogStatus = 'create'
  573. this.create.dialogFormVisible = true
  574. },
  575. createData() {
  576. console.log('点击了新增保存')
  577. this.isokDisable = true
  578. setTimeout(() => {
  579. this.isokDisable = false
  580. }, 1000)
  581. this.$refs['temp'].validate(valid => {
  582. if (valid) {
  583. this.isokDisable = true
  584. setTimeout(() => {
  585. this.isokDisable = false
  586. }, 1000)
  587. const score = /^\d*$/
  588. // 2.5分-/2.75分/3分/3.25分/3.5分/3.75分/4分+
  589. if (!score.test(parseFloat(this.create.temp.score25)) || !score.test(parseFloat(this.create.temp.score275)) || !score.test(parseFloat(this.create.temp.score3)) || !score.test(parseFloat(this.create.temp.score325)) || !score.test(parseFloat(this.create.temp.score35)) || !score.test(parseFloat(this.create.temp.score375)) || !score.test(parseFloat(this.create.temp.score4))) {
  590. this.$message({ type: 'error', message: '牛头数请输入大于等于0的整数', duration: 2000 })
  591. return false
  592. }
  593. this.requestParam.name = 'insertBodyscore'
  594. this.requestParam.parammaps = this.create.temp
  595. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  596. PostDataByName(this.requestParam).then(response => {
  597. console.log('新增保存发送参数', this.requestParam)
  598. if (response.msg !== 'fail') {
  599. this.saveData()
  600. } else {
  601. const isRepeat = new RegExp('Duplicate entry :ds')
  602. if (isRepeat.test(response.data)) {
  603. this.$notify({ type: 'error', message: '同一栏舍不可重复录入', duration: 2000 })
  604. } else {
  605. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  606. }
  607. }
  608. })
  609. }
  610. })
  611. },
  612. saveData() {
  613. this.requestParam2.name = 'insertDungandbodyhistory2'
  614. this.create.temp.pastureid = Cookies.get('pastureid')
  615. this.create.temp.changetime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')
  616. this.create.temp.species = 'tkpf'
  617. this.create.temp.fourrate = ''
  618. this.create.temp.fourweight = ''
  619. this.requestParam2.parammaps = this.create.temp
  620. PostDataByName(this.requestParam2).then(response => {
  621. console.log('新增保存发送参数', this.requestParam1)
  622. if (response.msg !== 'fail') {
  623. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  624. this.create.dialogFormVisible = false
  625. this.getList()
  626. } else {
  627. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  628. }
  629. })
  630. },
  631. createDataAgain() {
  632. console.log('点击了新增保存')
  633. this.isokDisable = true
  634. setTimeout(() => {
  635. this.isokDisable = false
  636. }, 1000)
  637. this.$refs['temp'].validate(valid => {
  638. if (valid) {
  639. this.isokDisable = true
  640. setTimeout(() => {
  641. this.isokDisable = false
  642. }, 1000)
  643. const score = /^\d*$/
  644. // 2.5分-/2.75分/3分/3.25分/3.5分/3.75分/4分+
  645. if (!score.test(parseFloat(this.create.temp.score25)) || !score.test(parseFloat(this.create.temp.score275)) || !score.test(parseFloat(this.create.temp.score3)) || !score.test(parseFloat(this.create.temp.score325)) || !score.test(parseFloat(this.create.temp.score35)) || !score.test(parseFloat(this.create.temp.score375)) || !score.test(parseFloat(this.create.temp.score4))) {
  646. this.$message({ type: 'error', message: '牛头数请输入大于等于0的整数', duration: 2000 })
  647. return false
  648. }
  649. this.requestParam.name = 'insertBodyscore'
  650. this.requestParam.parammaps = this.create.temp
  651. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  652. PostDataByName(this.requestParam).then(response => {
  653. console.log('新增保存发送参数', this.requestParam)
  654. if (response.msg !== 'fail') {
  655. this.saveData()
  656. this.resetTemp()
  657. this.getList()
  658. this.getNoteTakerList()
  659. } else {
  660. const isRepeat = new RegExp('Duplicate entry :ds')
  661. if (isRepeat.test(response.data)) {
  662. this.$notify({ type: 'error', message: '同一栏舍不可重复录入', duration: 2000 })
  663. } else {
  664. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  665. }
  666. }
  667. })
  668. }
  669. })
  670. },
  671. // 编辑
  672. handleUpdate(row) {
  673. console.log('点击了编辑', row)
  674. row.barid = String(row.barid)
  675. row.score25 = String(row.score25)
  676. row.score275 = String(row.score275)
  677. row.score3 = String(row.score3)
  678. row.score325 = String(row.score325)
  679. row.score35 = String(row.score35)
  680. row.score375 = String(row.score375)
  681. row.score4 = String(row.score4)
  682. this.create.temp = Object.assign({}, row)
  683. this.create.temp.id = row.id
  684. this.getNoteTakerList()
  685. this.dialogFull = false
  686. this.create.dialogStatus = 'update'
  687. this.create.dialogFormVisible = true
  688. },
  689. updateData() {
  690. this.isokDisable = true
  691. setTimeout(() => {
  692. this.isokDisable = false
  693. }, 1000)
  694. this.$refs['temp'].validate(valid => {
  695. if (valid) {
  696. this.isokDisable = true
  697. setTimeout(() => {
  698. this.isokDisable = false
  699. }, 1000)
  700. const score = /^\d*$/
  701. // 2.5分-/2.75分/3分/3.25分/3.5分/3.75分/4分+
  702. if (!score.test(parseFloat(this.create.temp.score25)) || !score.test(parseFloat(this.create.temp.score275)) || !score.test(parseFloat(this.create.temp.score3)) || !score.test(parseFloat(this.create.temp.score325)) || !score.test(parseFloat(this.create.temp.score35)) || !score.test(parseFloat(this.create.temp.score375)) || !score.test(parseFloat(this.create.temp.score4))) {
  703. this.$message({ type: 'error', message: '牛头数请输入大于等于0的整数', duration: 2000 })
  704. return false
  705. }
  706. this.requestParam.name = 'updateBodyscore'
  707. this.requestParam.parammaps = this.create.temp
  708. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  709. PostDataByName(this.requestParam).then(response => {
  710. console.log('新增保存发送参数', this.requestParam)
  711. if (response.msg !== 'fail') {
  712. this.saveData()
  713. } else {
  714. const isRepeat = new RegExp('Duplicate entry :ds')
  715. if (isRepeat.test(response.data)) {
  716. this.$notify({ type: 'error', message: '同一栏舍不可重复录入', duration: 2000 })
  717. } else {
  718. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  719. }
  720. }
  721. })
  722. }
  723. })
  724. },
  725. // 删除
  726. handleRowDelete(row) {
  727. console.log('点击了行内删除')
  728. MessageBox.confirm('是否确认删除此信息?', {
  729. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  730. }).then(() => {
  731. this.selectList = []
  732. this.requestParam.name = 'deleteBodyscore'
  733. this.requestParam.parammaps = {}
  734. this.requestParam.parammaps.pastureid = row.pastureid
  735. this.requestParam.parammaps.id = row.id
  736. PostDataByName(this.requestParam).then(response => {
  737. if (response.msg === 'fail') {
  738. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  739. } else {
  740. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  741. this.getList()
  742. }
  743. })
  744. }).catch(() => {
  745. this.$message({ type: 'info', message: '已取消删除' })
  746. })
  747. },
  748. handleSelectionChange(val) {
  749. console.log('勾选数据', val)
  750. this.selectList = val
  751. },
  752. handleDelete() {
  753. console.log('点击了删除')
  754. if (this.selectList.length == 0) {
  755. this.$message({ type: 'error', message: '请选择体况评分', duration: 2000 })
  756. } else {
  757. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  758. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  759. }).then(() => {
  760. console.log(this.selectList)
  761. this.requestParam.common = { 'returnmap': '0' }
  762. this.requestParam.data = []
  763. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  764. this.requestParam.data[0].children = []
  765. this.requestParam.data[0].children[0] = { 'name': 'deleteBodyscore', 'type': 'e', 'parammaps': {
  766. id: '@insertSpotList.id',
  767. pastureid: '@insertSpotList.pastureid'
  768. }}
  769. ExecDataByConfig(this.requestParam).then(response => {
  770. console.log('删除保存发送参数', this.requestParam)
  771. if (response.msg === 'fail') {
  772. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  773. } else {
  774. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  775. this.getList()
  776. }
  777. })
  778. })
  779. }
  780. },
  781. // 复制
  782. handleCopy() {
  783. console.log('点击了复制')
  784. if (this.selectList.length == 0) {
  785. this.$message({ type: 'error', message: '请选择体况评分', duration: 2000 })
  786. } else if (this.selectList.length == 1) {
  787. MessageBox.confirm('是否确认复制此信息?', {
  788. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  789. }).then(() => {
  790. this.requestParam.name = 'copyBodyscore'
  791. this.requestParam.parammaps = {}
  792. this.requestParam.parammaps.pastureid = this.selectList[0].pastureid
  793. this.requestParam.parammaps.id = this.selectList[0].id
  794. PostDataByName(this.requestParam).then(response => {
  795. if (response.msg === 'fail') {
  796. const isRepeat = new RegExp('Duplicate entry :ds')
  797. if (isRepeat.test(response.data)) {
  798. this.$notify({ type: 'error', message: '同一栏舍不可重复录入', duration: 2000 })
  799. } else {
  800. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  801. }
  802. } else {
  803. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  804. this.getList()
  805. }
  806. })
  807. }).catch(() => {
  808. this.$message({ type: 'info', message: '已取消删除' })
  809. })
  810. } else {
  811. this.$message({ type: 'error', message: '请选择一条体况评分', duration: 2000 })
  812. }
  813. },
  814. // 导出
  815. handleExport(item) {
  816. if (item == 1) {
  817. console.log('点击了导出模板')
  818. const requestParam = this.requestParam
  819. const url = process.env.VUE_APP_BASE_API + 'file/导入导出模板/栏舍生产/体况评分导入模板.xlsx' // 请求下载文件的地址
  820. console.log(url)
  821. axios({
  822. method: 'GET',
  823. url: url,
  824. data: requestParam,
  825. headers: { token: getToken(), optname: 'insertcustomdoc' },
  826. responseType: 'blob'
  827. }).then(res => {
  828. if (!res) return
  829. this.percentage = 99
  830. setTimeout(() => {
  831. this.isPercentage = false
  832. }, 2000)
  833. const blob = new Blob([res.data], {
  834. type: 'application/octet-stream;charset=utf-8'
  835. })
  836. const url = window.URL.createObjectURL(blob)
  837. const aLink = document.createElement('a')
  838. aLink.style.display = 'none'
  839. aLink.href = url
  840. const docname = '体况评分导入模板.xlsx'
  841. aLink.setAttribute('download', docname) // 下载的文件
  842. document.body.appendChild(aLink)
  843. aLink.click()
  844. document.body.removeChild(aLink)
  845. window.URL.revokeObjectURL(url)
  846. })
  847. } else {
  848. console.log('点击了导出数据')
  849. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  850. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  851. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  852. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  853. } else {
  854. this.download.getdataListParm.parammaps.inputDatetime = ''
  855. this.download.getdataListParm.parammaps.startTime = ''
  856. this.download.getdataListParm.parammaps.stopTime = ''
  857. }
  858. GetDataByName(this.download.getdataListParm).then(response => {
  859. if (response.data.list !== null) {
  860. this.download.list = response.data.list
  861. } else {
  862. this.download.list = []
  863. }
  864. var excelDatas = [
  865. {
  866. tHeader: ['栏舍名称', '标准分数(分)', '牛头数(头)', '2.75-分(头)', '2.75分(头)', '3分(头)', '3.25分(头)', '3.5分(头)', '3.75分(头)', '4+分(头)', '备注', '操作人', '操作日期'],
  867. filterVal: ['barname', 'standardscore', 'cowsum', 'score25', 'score275', 'score3', 'score325', 'score35', 'score375', 'score4', 'remark', 'emp', 'operatetime'],
  868. tableDatas: this.download.list,
  869. sheetName: 'Sheet1'
  870. }
  871. ]
  872. json2excel(excelDatas, '体况评分', true, 'xlsx')
  873. })
  874. }
  875. },
  876. beforeImport(file) {
  877. const isLt2M = file.size / 1024 / 1024 < 2
  878. if (!isLt2M) {
  879. this.$message.error('上传文件大小不能超过 2MB!')
  880. }
  881. return isLt2M
  882. },
  883. handleImportSuccess(res, file) {
  884. this.getList()
  885. if (res.msg === 'ok') {
  886. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  887. if (res.data.err_count > 0) {
  888. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  889. import('@/vendor/Export2Excel').then(excel => {
  890. const list1 = res.data.result
  891. const tHeader = [
  892. '栏舍名称', '2.75-分(头)', '2.75分(头)', '3分(头)', '3.25分(头)', '3.5分(头)', '3.75分(头)', '4+分(头)', '备注', '操作人', '操作日期', '错误信息'
  893. ]
  894. const filterVal = [
  895. '栏舍名称', '2.75-分(头)', '2.75分(头)', '3分(头)', '3.25分(头)', '3.5分(头)', '3.75分(头)', '4+分(头)', '备注', '操作人', '操作日期', 'error_msg'
  896. ]
  897. const data1 = this.formatJson(filterVal, list1)
  898. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '体况评分导入报错信息', autoWidth: true, bookType: 'xlsx' })
  899. })
  900. }
  901. } else {
  902. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  903. }
  904. },
  905. formatJson(filterVal, jsonData) {
  906. return jsonData.map(v =>
  907. filterVal.map(j => {
  908. if (j === 'timestamp') {
  909. return parseTime(v[j])
  910. } else {
  911. return v[j]
  912. }
  913. })
  914. )
  915. },
  916. handleHistoryRecord() {
  917. console.log('点击历史记录')
  918. this.dialogFull = false
  919. this.historyRecord.dialogStatus = 'historyRecord'
  920. this.historyRecord.dialogFormVisible = true
  921. const vue = this
  922. var myComponent = () => import('./historyRecord.vue')
  923. return vue.historyRecord.myComponent = myComponent
  924. }
  925. }
  926. }
  927. </script>
  928. <style lang="scss" scoped>
  929. .search{padding-top:10px;clear: both;}
  930. .table{margin-top:10px;}
  931. </style>