a9ab302d0c3710777b879ba37f1ab212c12ec333.svn-base 42 KB

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