0527486f1c969c80bfd0ae159de33957dcd40aa4.svn-base 38 KB

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