2a97bb398303903142172d14114616d17ec8f0fd.svn-base 39 KB

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