index.vue 44 KB

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