327531f75772e1d5367ff9db55fdd62e824c4f4f.svn-base 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button v-if="isRoleEdit" class="success" style="float: left;margin-right:10px;" @click="handleCreate">新增</el-button>
  5. <el-button v-if="isRoleEdit" class="danger" style="float: left;margin-right:10px;" @click="handleDelete">删除</el-button>
  6. <el-button v-if="isRoleEdit" class="warning" style="float: left;margin-right:10px;" @click="handleCopy">复制</el-button>
  7. <el-button v-if="isRoleEdit" class="import" style="float: right;" @click="handleImport">导入</el-button>
  8. <el-dropdown style="float: right;margin-right: 10px;">
  9. <el-button class="export">导出</el-button>
  10. <el-dropdown-menu slot="dropdown">
  11. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  12. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  13. </el-dropdown-menu>
  14. </el-dropdown>
  15. </div>
  16. <div class="search">
  17. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  18. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  19. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  20. <el-select v-model="table.getdataListParm.parammaps.barid" placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  21. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  22. </el-select>
  23. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  24. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  25. </div>
  26. <div class="table">
  27. <el-table
  28. :key="table.tableKey"
  29. v-loading="table.listLoading"
  30. element-loading-text="给我一点时间"
  31. :data="table.list"
  32. border
  33. fit
  34. highlight-current-row
  35. style="width: 100%;"
  36. :row-style="rowStyle"
  37. :cell-style="cellStyle"
  38. class="elTable table-fixed"
  39. @selection-change="handleSelectionChange"
  40. >
  41. <el-table-column type="selection" align="center" width="50" />
  42. <el-table-column label="序号" align="center" type="index" width="50px">
  43. <template slot-scope="scope">
  44. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</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.barname }}</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.times }}</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.cowsum }}</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="评分" align="center">
  63. <el-table-column label="1分(头)" min-width="100px" align="center">
  64. <template slot-scope="scope">
  65. <span>{{ scope.row.score1 }}({{ scope.row.score1rate }}%)</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="2分(头)" min-width="100px" align="center">
  69. <template slot-scope="scope">
  70. <span>{{ scope.row.score2 }}({{ scope.row.score2rate }}%)</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="3分(头)" min-width="100px" align="center">
  74. <template slot-scope="scope">
  75. <span>{{ scope.row.score3 }}({{ scope.row.score3rate }}%)</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="4分(头)" min-width="100px" align="center">
  79. <template slot-scope="scope">
  80. <span>{{ scope.row.score4 }}({{ scope.row.score4rate }}%)</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="5分(头)" min-width="100px" align="center">
  84. <template slot-scope="scope">
  85. <span>{{ scope.row.score5 }}({{ scope.row.score5rate }}%)</span>
  86. </template>
  87. </el-table-column>
  88. </el-table-column>
  89. <el-table-column label="备注" min-width="90px" align="center">
  90. <template slot-scope="scope">
  91. <span>{{ scope.row.remark }}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="操作人" min-width="90px" align="center">
  95. <template slot-scope="scope">
  96. <span>{{ scope.row.emp }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="操作日期" min-width="90px" align="center">
  100. <template slot-scope="scope">
  101. <span>{{ scope.row.operatetime }}</span>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  105. <template slot-scope="{row}">
  106. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  107. <el-button v-if="isRoleEdit" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  112. </div>
  113. <!-- 新增/编辑 -->
  114. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  115. <div class="app-add">
  116. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="150px" style="width: 100%;margin:0 auto 50px">
  117. <el-row>
  118. <el-col :span="24">
  119. <h3 style="width: 150px;text-align: right;">栏舍信息</h3>
  120. </el-col>
  121. </el-row>
  122. <el-row>
  123. <el-col :span="6">
  124. <el-form-item label="栏舍名称:" prop="barid">
  125. <el-select ref="barid" v-model="create.temp.barid" filterable placeholder="栏舍名称" class="filter-item" style="width: 100%;" @change="changeBar">
  126. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  127. </el-select>
  128. </el-form-item>
  129. </el-col>
  130. </el-row>
  131. <el-row>
  132. <el-col :span="24">
  133. <h3 style="width: 150px;text-align: right;">评分</h3>
  134. </el-col>
  135. </el-row>
  136. <el-row>
  137. <el-col :span="6">
  138. <el-form-item label="标准分数(分):" prop="standardscore">
  139. <el-input ref="standardscore" v-model="create.temp.standardscore" class="filter-item" style="width: 100%;" disabled />
  140. </el-form-item>
  141. </el-col>
  142. <el-col :span="6">
  143. <el-form-item label="牛头数(头):" prop="cowsum">
  144. <el-input ref="cowsum" v-model="create.temp.cowsum" class="filter-item" style="width: 100%;" disabled />
  145. </el-form-item>
  146. </el-col>
  147. <el-col :span="6">
  148. <el-form-item label="1分" prop="score1">
  149. <el-input ref="score1" v-model="create.temp.score1" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  150. </el-form-item>
  151. </el-col>
  152. <el-col :span="6">
  153. <el-form-item label="2分" prop="score2">
  154. <el-input ref="score2" v-model="create.temp.score2" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  155. </el-form-item>
  156. </el-col>
  157. </el-row>
  158. <el-row>
  159. <el-col :span="6">
  160. <el-form-item label="3分" prop="score3">
  161. <el-input ref="score3" v-model="create.temp.score3" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  162. </el-form-item>
  163. </el-col>
  164. <el-col :span="6">
  165. <el-form-item label="4分" prop="score4">
  166. <el-input ref="score4" v-model="create.temp.score4" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  167. </el-form-item>
  168. </el-col>
  169. <el-col :span="6">
  170. <el-form-item label="5分" prop="score5">
  171. <el-input ref="score5" v-model="create.temp.score5" class="filter-item" placeholder="牛头数" type="number" style="width: 100%;" @blur="blurScore" />
  172. </el-form-item>
  173. </el-col>
  174. </el-row>
  175. <el-row>
  176. <el-col :span="24">
  177. <h3 style="width: 150px;text-align: right;">操作详情</h3>
  178. </el-col>
  179. </el-row>
  180. <el-row>
  181. <el-col :span="6">
  182. <el-form-item label="操作人:" prop="emp">
  183. <el-select ref="emp" v-model="create.temp.emp" filterable placeholder="操作人" class="filter-item" style="width: 100%;" @blur="blurEmp">
  184. <el-option v-for="item in create.noteTakerList" :key="item.myId" :label="item.emp" :value="item.emp" />
  185. </el-select>
  186. </el-form-item>
  187. </el-col>
  188. <el-col :span="6">
  189. <el-form-item label="操作日期:" prop="operatetime">
  190. <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" />
  191. </el-form-item>
  192. </el-col>
  193. <el-col :span="12">
  194. <el-form-item label="备注:" prop="remark">
  195. <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%;" />
  196. </el-form-item>
  197. </el-col>
  198. </el-row>
  199. </el-form>
  200. <div slot="footer" class="dialog-footer">
  201. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  202. <el-button v-if="create.dialogStatus==='create'" class="success" :disabled="isokDisable" @click="createDataAgain()">确认新增</el-button>
  203. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  204. </div>
  205. </div>
  206. </el-dialog>
  207. </div>
  208. </template>
  209. <script>
  210. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  211. import Cookies from 'js-cookie'
  212. import { parseTime } from '@/utils/index.js'
  213. import Pagination from '@/components/Pagination'
  214. import { MessageBox } from 'element-ui'
  215. export default {
  216. name: 'DungScores',
  217. components: { Pagination },
  218. data() {
  219. return {
  220. isRoleEdit: [],
  221. requestParams: [
  222. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }},
  223. { name: 'getSysoptEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid'), 'inforname': 'times' }}
  224. ],
  225. houseNameList: [], // 栏舍名称
  226. frequencyList: [], // 班次
  227. table: {
  228. getdataListParm: {
  229. name: 'getDungscoreList',
  230. page: 1,
  231. offset: 1,
  232. pagecount: 10,
  233. returntype: 'Map',
  234. parammaps: {
  235. pastureid: Cookies.get('pastureid'),
  236. barid: '',
  237. times: '',
  238. startTime: '',
  239. stopTime: '',
  240. inputDatetime: ''
  241. }
  242. },
  243. tableKey: 0,
  244. list: [],
  245. total: 0,
  246. listLoading: true,
  247. temp: {}
  248. },
  249. // 新增/编辑
  250. create: {
  251. dialogFormVisible: false,
  252. dialogStatus: '',
  253. 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: '' },
  254. rules: {
  255. barid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  256. times: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  257. score1: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  258. score2: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  259. score3: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  260. score4: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  261. score5: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  262. },
  263. // 操作人
  264. getdataListParm: {
  265. name: 'getDungscoreEmpHis',
  266. page: 1,
  267. offset: 1,
  268. pagecount: 10,
  269. returntype: 'Map',
  270. parammaps: {
  271. pastureid: Cookies.get('pastureid')
  272. }
  273. },
  274. // 粪便评分参数
  275. getdataListParm2: {
  276. name: 'getDungAndBodyScore',
  277. page: 1,
  278. offset: 1,
  279. pagecount: 1,
  280. returntype: 'Map',
  281. parammaps: {
  282. pastureid: Cookies.get('pastureid'),
  283. barid: '',
  284. date: ''
  285. }
  286. },
  287. noteTakerList: [] // 记录人
  288. },
  289. textMap: {
  290. create: '新增',
  291. update: '编辑'
  292. },
  293. requestParam: {},
  294. isokDisable: false,
  295. selectList: [],
  296. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  297. cellStyle: { padding: 0 + 'px' }
  298. }
  299. },
  300. created() {
  301. this.getList()
  302. this.getDownList()
  303. this.getButtons()
  304. },
  305. methods: {
  306. getButtons() {
  307. const Edit = 'DungScores'
  308. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  309. this.isRoleEdit = isRoleEdit
  310. },
  311. getDownList() {
  312. GetDataByNames(this.requestParams).then(response => {
  313. this.houseNameList = response.data.getBarListEnable.list
  314. if (response.data.getSysoptEnable.list !== null) {
  315. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  316. const obj = {}
  317. obj.id = String(i)
  318. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  319. this.frequencyList.push(obj)
  320. }
  321. } else {
  322. this.frequencyList = []
  323. }
  324. })
  325. },
  326. handleBefore() {
  327. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  328. var start = this.table.getdataListParm.parammaps.inputDatetime[0] - 3600 * 1000 * 24
  329. var stop = this.table.getdataListParm.parammaps.inputDatetime[1] - 3600 * 1000 * 24
  330. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  331. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  332. this.$forceUpdate()
  333. }
  334. },
  335. handleNext() {
  336. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  337. var start = this.table.getdataListParm.parammaps.inputDatetime[0] + 3600 * 1000 * 24
  338. var stop = this.table.getdataListParm.parammaps.inputDatetime[1] + 3600 * 1000 * 24
  339. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  340. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  341. this.$forceUpdate()
  342. }
  343. },
  344. getList() {
  345. this.table.listLoading = true
  346. GetDataByName(this.table.getdataListParm).then(response => {
  347. console.log('table数据', response.data.list)
  348. if (response.data.list !== null) {
  349. for (let i = 0; i < response.data.list.length; i++) {
  350. this.$set(response.data.list[i], 'score1rate', (parseFloat(response.data.list[i].score1) / parseFloat(response.data.list[i].cowsum) * 100).toFixed(2))
  351. this.$set(response.data.list[i], 'score2rate', (parseFloat(response.data.list[i].score2) / parseFloat(response.data.list[i].cowsum) * 100).toFixed(2))
  352. this.$set(response.data.list[i], 'score3rate', (parseFloat(response.data.list[i].score3) / parseFloat(response.data.list[i].cowsum) * 100).toFixed(2))
  353. this.$set(response.data.list[i], 'score4rate', (parseFloat(response.data.list[i].score4) / parseFloat(response.data.list[i].cowsum) * 100).toFixed(2))
  354. 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))
  355. }
  356. this.table.list = response.data.list
  357. this.table.pageNum = response.data.pageNum
  358. this.table.pageSize = response.data.pageSize
  359. this.table.total = response.data.total
  360. } else {
  361. this.table.list = []
  362. }
  363. setTimeout(() => {
  364. this.table.listLoading = false
  365. }, 100)
  366. })
  367. },
  368. handleSearch() {
  369. console.log('点击了查询')
  370. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  371. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  372. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  373. } else {
  374. this.table.getdataListParm.parammaps.inputDatetime = ''
  375. this.table.getdataListParm.parammaps.startTime = ''
  376. this.table.getdataListParm.parammaps.stopTime = ''
  377. }
  378. this.table.getdataListParm.offset = 1
  379. this.getList()
  380. },
  381. handleRefresh() {
  382. console.log('点击了重置')
  383. this.table.getdataListParm.parammaps.barid = ''
  384. this.table.getdataListParm.parammaps.times = ''
  385. this.table.getdataListParm.parammaps.startTime = ''
  386. this.table.getdataListParm.parammaps.stopTime = ''
  387. this.table.getdataListParm.parammaps.inputDatetime = ''
  388. this.table.getdataListParm.offset = 1
  389. this.getList()
  390. },
  391. // 新增
  392. resetTemp() {
  393. 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: '' }
  394. },
  395. blurEmp(item) {
  396. this.create.temp.emp = item.target.value
  397. },
  398. // 栏舍名称
  399. changeBar(item) {
  400. this.create.temp.barname = this.houseNameList.find(obj => obj.id === item).bname
  401. this.getRange()
  402. },
  403. changeOperatetime() {
  404. this.getRange()
  405. },
  406. // 粪便评分参数
  407. getRange() {
  408. this.create.getdataListParm2.parammaps.date = this.create.temp.operatetime
  409. this.create.getdataListParm2.parammaps.barid = this.create.temp.barid
  410. GetDataByName(this.create.getdataListParm2).then(response => {
  411. if (response.data.list !== null) {
  412. this.create.temp.standardscore = response.data.list[0].dungstandard
  413. this.create.temp.ftid = response.data.list[0].ftid
  414. this.create.temp.ftname = response.data.list[0].ftname
  415. } else {
  416. this.create.temp.standardscore = ''
  417. this.create.temp.ftid = ''
  418. this.create.temp.ftname = ''
  419. }
  420. })
  421. },
  422. // 操作人
  423. getNoteTakerList() {
  424. GetDataByName(this.create.getdataListParm).then(response => {
  425. if (response.data.list !== null) {
  426. for (let i = 0; i < response.data.list.length; i++) {
  427. response.data.list[i].myId = i
  428. }
  429. this.create.noteTakerList = response.data.list
  430. console.log('记录人数据', response.data.list)
  431. console.log(this.create.noteTakerList)
  432. } else {
  433. this.create.noteTakerList = []
  434. }
  435. })
  436. },
  437. blurScore() {
  438. if (this.create.temp.score1 !== '' && this.create.temp.score2 !== '' && this.create.temp.score3 !== '' && this.create.temp.score4 !== '' && this.create.temp.score5 !== '') {
  439. 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)
  440. }
  441. },
  442. handleCreate() {
  443. console.log('点击了新增')
  444. this.resetTemp()
  445. this.getNoteTakerList()
  446. this.create.dialogStatus = 'create'
  447. this.create.dialogFormVisible = true
  448. },
  449. createData() {
  450. console.log('点击了新增保存')
  451. this.isokDisable = true
  452. setTimeout(() => {
  453. this.isokDisable = false
  454. }, 1000)
  455. this.$refs['temp'].validate(valid => {
  456. if (valid) {
  457. this.isokDisable = true
  458. setTimeout(() => {
  459. this.isokDisable = false
  460. }, 1000)
  461. const score = /^\d*$/
  462. // 1分/2分/3分/4分/5分
  463. 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))) {
  464. this.$message({ type: 'error', message: '牛头数请输入大于等于0的整数', duration: 2000 })
  465. return false
  466. }
  467. this.requestParam.name = 'insertDungscore'
  468. this.requestParam.parammaps = this.create.temp
  469. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  470. PostDataByName(this.requestParam).then(response => {
  471. console.log('新增保存发送参数', this.requestParam)
  472. if (response.msg !== 'fail') {
  473. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  474. this.create.dialogFormVisible = false
  475. this.getList()
  476. } else {
  477. failproccess(response, this.$notify)
  478. }
  479. })
  480. }
  481. })
  482. },
  483. createDataAgain() {
  484. console.log('点击了新增保存')
  485. this.isokDisable = true
  486. setTimeout(() => {
  487. this.isokDisable = false
  488. }, 1000)
  489. this.$refs['temp'].validate(valid => {
  490. if (valid) {
  491. this.isokDisable = true
  492. setTimeout(() => {
  493. this.isokDisable = false
  494. }, 1000)
  495. const score = /^\d*$/
  496. // 1分/2分/3分/4分/5分
  497. 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))) {
  498. this.$message({ type: 'error', message: '牛头数请输入大于等于0的整数', duration: 2000 })
  499. return false
  500. }
  501. this.requestParam.name = 'insertDungscore'
  502. this.requestParam.parammaps = this.create.temp
  503. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  504. PostDataByName(this.requestParam).then(response => {
  505. console.log('新增保存发送参数', this.requestParam)
  506. if (response.msg !== 'fail') {
  507. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  508. this.resetTemp()
  509. this.getList()
  510. this.getNoteTakerList()
  511. } else {
  512. failproccess(response, this.$notify)
  513. }
  514. })
  515. }
  516. })
  517. },
  518. // 编辑
  519. handleUpdate(row) {
  520. console.log('点击了编辑', row)
  521. row.barid = String(row.barid)
  522. row.score1 = String(row.score1)
  523. row.score2 = String(row.score2)
  524. row.score3 = String(row.score3)
  525. row.score4 = String(row.score4)
  526. row.score5 = String(row.score5)
  527. this.create.temp = Object.assign({}, row)
  528. this.create.temp.id = row.id
  529. this.getNoteTakerList()
  530. this.create.dialogStatus = 'update'
  531. this.create.dialogFormVisible = true
  532. },
  533. updateData() {
  534. this.isokDisable = true
  535. setTimeout(() => {
  536. this.isokDisable = false
  537. }, 1000)
  538. this.$refs['temp'].validate(valid => {
  539. if (valid) {
  540. this.isokDisable = true
  541. setTimeout(() => {
  542. this.isokDisable = false
  543. }, 1000)
  544. const score = /^\d*$/
  545. // 1分/2分/3分/4分/5分
  546. 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))) {
  547. this.$message({ type: 'error', message: '牛头数请输入大于等于0的整数', duration: 2000 })
  548. return false
  549. }
  550. this.requestParam.name = 'updateDungscore'
  551. this.requestParam.parammaps = this.create.temp
  552. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  553. PostDataByName(this.requestParam).then(response => {
  554. console.log('新增保存发送参数', this.requestParam)
  555. if (response.msg !== 'fail') {
  556. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  557. this.create.dialogFormVisible = false
  558. this.getList()
  559. } else {
  560. failproccess(response, this.$notify)
  561. }
  562. })
  563. }
  564. })
  565. },
  566. // 删除
  567. handleRowDelete(row) {
  568. console.log('点击了行内删除')
  569. MessageBox.confirm('是否确认删除此信息?', {
  570. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  571. }).then(() => {
  572. this.selectList = []
  573. this.requestParam.name = 'deleteDungscore'
  574. this.requestParam.parammaps = {}
  575. this.requestParam.parammaps.pastureid = row.pastureid
  576. this.requestParam.parammaps.id = row.id
  577. PostDataByName(this.requestParam).then(response => {
  578. if (response.msg === 'fail') {
  579. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  580. } else {
  581. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  582. this.getList()
  583. }
  584. })
  585. }).catch(() => {
  586. this.$message({ type: 'info', message: '已取消删除' })
  587. })
  588. },
  589. handleSelectionChange(val) {
  590. console.log('勾选数据', val)
  591. this.selectList = val
  592. },
  593. handleDelete() {
  594. console.log('点击了删除')
  595. if (this.selectList.length == 0) {
  596. this.$message({ type: 'error', message: '请选择粪便评分', duration: 2000 })
  597. } else {
  598. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  599. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  600. }).then(() => {
  601. console.log(this.selectList)
  602. this.requestParam.common = { 'returnmap': '0' }
  603. this.requestParam.data = []
  604. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  605. this.requestParam.data[0].children = []
  606. this.requestParam.data[0].children[0] = { 'name': 'deleteDungscore', 'type': 'e', 'parammaps': {
  607. id: '@insertSpotList.id',
  608. pastureid: '@insertSpotList.pastureid'
  609. }}
  610. ExecDataByConfig(this.requestParam).then(response => {
  611. console.log('删除保存发送参数', this.requestParam)
  612. if (response.msg === 'fail') {
  613. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  614. } else {
  615. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  616. this.getList()
  617. }
  618. })
  619. })
  620. }
  621. },
  622. // 复制
  623. handleCopy() {
  624. console.log('点击了复制')
  625. if (this.selectList.length == 0) {
  626. this.$message({ type: 'error', message: '请选择粪便评分', duration: 2000 })
  627. } else if (this.selectList.length == 1) {
  628. MessageBox.confirm('是否确认复制此信息?', {
  629. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  630. }).then(() => {
  631. this.requestParam.name = 'copyDungscore'
  632. this.requestParam.parammaps = {}
  633. this.requestParam.parammaps.pastureid = this.selectList[0].pastureid
  634. this.requestParam.parammaps.id = this.selectList[0].id
  635. PostDataByName(this.requestParam).then(response => {
  636. if (response.msg === 'fail') {
  637. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  638. } else {
  639. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  640. this.getList()
  641. }
  642. })
  643. }).catch(() => {
  644. this.$message({ type: 'info', message: '已取消删除' })
  645. })
  646. } else {
  647. this.$message({ type: 'error', message: '请选择一条粪便评分', duration: 2000 })
  648. }
  649. },
  650. // 导出
  651. handleExport(item) {
  652. if (item == 1) {
  653. console.log('点击了导出模板')
  654. } else {
  655. console.log('点击了导出数据')
  656. }
  657. },
  658. // 导入
  659. handleImport() {
  660. console.log('点击了导入')
  661. }
  662. }
  663. }
  664. </script>
  665. <style lang="scss" scoped>
  666. .search{padding-top:10px;clear: both;}
  667. .table{margin-top:10px;}
  668. </style>