index.vue 43 KB

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