67b7b30a2f5c2dbd2fe4a394980b2fcde1b167ce.svn-base 30 KB

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