dd53ad7c4452f7e4d938a10b6dd080e5d6f7f656.svn-base 33 KB

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