index.vue 42 KB

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