50df207f03616b1126d328ce53ec085b1d68a04a.svn-base 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button class="success" @click="handleCreate">新增</el-button>
  5. <el-upload style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  6. <el-button class="import" style="float: right;">导入</el-button>
  7. </el-upload>
  8. <el-dropdown style="float: right;margin-right: 10px;">
  9. <el-button class="export">导出</el-button>
  10. <el-dropdown-menu slot="dropdown">
  11. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  12. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  13. </el-dropdown-menu>
  14. </el-dropdown>
  15. </div>
  16. <div class="search">
  17. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  18. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  19. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  20. <el-select v-model="table.getdataListParm.parammaps.usetype" placeholder="操作类型" class="filter-item" style="width: 120px;" clearable>
  21. <el-option v-for="item in operationTypeList" :key="item.id" :label="item.label" :value="item.value" />
  22. </el-select>
  23. <el-autocomplete v-model="table.getdataListParm.parammaps.feedname" value-key="feedname" class="inline-input filter-item" :fetch-suggestions="tableFeedNameSearch" placeholder="饲料名称" style="width:250px" @select="handleSelectTableFeedName">
  24. <template slot-scope="{ item }">
  25. <span>{{ item.feedname }}</span>
  26. </template>
  27. </el-autocomplete>
  28. <el-select v-model="table.getdataListParm.parammaps.cowclassid" filterable placeholder="请选择牲畜类别" class="filter-item" style="width: 150px;" clearable>
  29. <el-option v-for="item in livestockList" :key="item.id" :label="item.mixname" :value="item.id" />
  30. </el-select>
  31. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  32. <el-button class="successBorder" @click="handleRefresh">重置</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. >
  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="130px" align="center">
  54. <template slot-scope="scope">
  55. <span>{{ scope.row.usedate }}</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="牲畜类别" min-width="130px" align="center">
  59. <template slot-scope="scope">
  60. <span>{{ scope.row.cowclass }}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="饲料名称" min-width="110px" align="center">
  64. <template slot-scope="scope">
  65. <span>{{ scope.row.feedname }}</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="操作重量(kg)" min-width="110px" align="center">
  69. <template slot-scope="scope">
  70. <span>{{ scope.row.operateweight }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="操作类型" min-width="110px" align="center">
  74. <template slot-scope="scope">
  75. <span>{{ scope.row.usetype }}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="备注" min-width="110px" align="center">
  79. <template slot-scope="scope">
  80. <span>{{ scope.row.remark }}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="操作人" min-width="110px" align="center">
  84. <template slot-scope="scope">
  85. <span>{{ scope.row.createemp }}</span>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
  89. <template slot-scope="{row}">
  90. <el-button class="miniPrimary" @click="handleSee(row)">查看</el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  95. </div>
  96. <!-- 新增/编辑 -->
  97. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="80%">
  98. <div class="app-add">
  99. <el-form ref="createTemp" :rules="create.rules" :model="create.createTemp" label-position="right" label-width="150px" style="width: 90%;height:300px;margin:0 auto 50px">
  100. <el-row>
  101. <el-col :span="12">
  102. <el-form-item label="操作类型:" prop="usetype">
  103. <el-select v-model="create.createTemp.usetype" placeholder="操作类型" class="filter-item" style="width: 100%;" :disabled="create.dialogStatus==='see'" @change="changeUsetype">
  104. <el-option v-for="item in operationTypeList" :key="item.id" :label="item.label" :value="item.value" />
  105. </el-select>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="12">
  109. <el-form-item label="出库日期:" prop="usedate">
  110. <el-date-picker v-model="create.createTemp.usedate" :picker-options="create.pickerOptions1" :clearable="false" class="filter-item" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 100%;" type="datetime" placeholder="出库日期" :disabled="create.dialogStatus==='see'" />
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. <el-row>
  115. <el-col :span="12">
  116. <el-form-item label="饲料名称:" prop="feedname">
  117. <el-autocomplete v-model="create.createTemp.feedname" :disabled="create.dialogStatus==='see'" value-key="feedname" class="inline-input" :fetch-suggestions="feedNameSearch" placeholder="请选择饲料名称" style="width:100%" @select="handleSelectFeedName" @blur="blurFeedName">
  118. <template slot-scope="{ item }">
  119. <span>{{ item.feedname }}</span>
  120. </template>
  121. </el-autocomplete>
  122. </el-form-item>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="12">
  126. <el-form-item label="牲畜类别:" prop="cowclassid">
  127. <el-select v-model="create.createTemp.cowclassid" filterable placeholder="请选择牲畜类别" class="filter-item" style="width: 100%;" :disabled="create.dialogStatus==='see' || create.createTemp.usetype=='损耗'" @change="changeLivestock">
  128. <el-option v-for="item in livestockList" :key="item.id" :label="item.mixname" :value="item.id" />
  129. </el-select>
  130. </el-form-item>
  131. </el-col>
  132. </el-row>
  133. <el-row>
  134. <el-col :span="12">
  135. <el-form-item label="库存重量(kg):" prop="repertoryweight">
  136. <el-input ref="repertoryweight" v-model="create.createTemp.repertoryweight" class="filter-item" placeholder="最多两位小数" type="text" disabled />
  137. </el-form-item>
  138. </el-col>
  139. <el-col :span="12">
  140. <el-form-item label="操作重量(kg):" prop="operateweight">
  141. <el-input ref="operateweight" v-model="create.createTemp.operateweight" class="filter-item" placeholder="最多两位小数" type="text" :disabled="create.dialogStatus==='see'" />
  142. </el-form-item>
  143. </el-col>
  144. </el-row>
  145. <el-row>
  146. <el-col :span="12">
  147. <el-form-item label="备注:" prop="remark">
  148. <el-input ref="remark" v-model="create.createTemp.remark" class="filter-item" placeholder="1-255字符" type="text" :disabled="create.dialogStatus==='see'" />
  149. </el-form-item>
  150. </el-col>
  151. <el-col :span="12">
  152. <el-form-item label="操作人:" prop="createemp">
  153. <el-input ref="createemp" v-model="create.createTemp.createemp" class="filter-item" placeholder="1-255字符" type="text" disabled />
  154. </el-form-item>
  155. </el-col>
  156. </el-row>
  157. </el-form>
  158. <div slot="footer" class="dialog-footer">
  159. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList();">关闭</el-button>
  160. <el-button v-if="create.dialogStatus==='create'" class="success" :disabled="isokDisable" @click="createData()">确认</el-button>
  161. </div>
  162. </div>
  163. </el-dialog>
  164. </div>
  165. </template>
  166. <script>
  167. import { GetDataByName, GetDataByNames, checkButtons, ExecDataByConfig, failproccess } from '@/api/common'
  168. import Pagination from '@/components/Pagination'
  169. import Cookies from 'js-cookie'
  170. import { parseTime, json2excel } from '@/utils/index.js'
  171. import { getToken } from '@/utils/auth'
  172. export default {
  173. name: 'LaborConsumption',
  174. components: { Pagination },
  175. data() {
  176. return {
  177. isRoleEdit: [],
  178. requestParams: [
  179. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['人工用量操作类型'] },
  180. { name: 'getCowclassListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }}
  181. ],
  182. operationTypeList: [], // 操作类型
  183. feedNameList: [], // 饲料名称
  184. livestockList: [], // 牲畜类别
  185. table: {
  186. getdataListParm: {
  187. name: 'getFeeduseList',
  188. page: 1,
  189. offset: 1,
  190. pagecount: 10,
  191. returntype: 'Map',
  192. parammaps: {
  193. inputDatetime: '',
  194. pastureid: Cookies.get('pastureid'),
  195. startTime: '',
  196. stopTime: '',
  197. usetype: '',
  198. feedid: '',
  199. cowclassid: ''
  200. }
  201. },
  202. tableKey: 0,
  203. list: [],
  204. total: 0,
  205. listLoading: true
  206. },
  207. create: {
  208. pickerOptions1: {
  209. disabledDate(time) {
  210. return time.getTime() > Date.now()// 当天之前的时间可选
  211. }
  212. },
  213. dialogFormVisible: false,
  214. dialogStatus: '',
  215. createTemp: {
  216. pastureid: Cookies.get('pastureid'), usedate: parseTime(new Date(), '{y}-{m}-{d}'), feedid: '', feedname: '', cowclassid: '', cowclass: '', usetype: '', operateweight: '', repertoryweight: '', createemp: '', remark: '', price: '', operator: Cookies.get('employename')
  217. },
  218. getfeedNameParm: {
  219. name: 'getFeedstorageuse',
  220. offset: 0,
  221. pagecount: '',
  222. parammaps: { pastureid: Cookies.get('pastureid') }
  223. },
  224. rules: {
  225. usetype: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  226. usedate: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  227. feedname: [{ type: 'string', required: true, message: '必填', trigger: 'change' }],
  228. operateweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  229. }
  230. },
  231. textMap: {
  232. create: '新增',
  233. see: '查看'
  234. },
  235. requestParam: {},
  236. download: {
  237. getdataListParm: {
  238. name: 'getFeeduseList',
  239. page: 1,
  240. offset: 1,
  241. pagecount: 0,
  242. returntype: 'Map',
  243. parammaps: {
  244. inputDatetime: '',
  245. pastureid: Cookies.get('pastureid'),
  246. startTime: '',
  247. stopTime: '',
  248. usetype: '',
  249. feedid: '',
  250. cowclassid: ''
  251. }
  252. },
  253. list: []
  254. },
  255. isokDisable: false,
  256. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  257. cellStyle: { padding: 0 + 'px' }
  258. }
  259. },
  260. computed: {
  261. // 设置请求头
  262. headers() {
  263. return {
  264. token: getToken()
  265. }
  266. },
  267. uploadData() {
  268. return {
  269. name: '颛孙洋洋-出库',
  270. importParams: '出库日期,操作类型,牲畜类别,饲料名称,操作重量(kg),备注,操作人',
  271. sheetname: 'SheetJS'
  272. }
  273. },
  274. // 设置上传地址
  275. uploadExcelUrl() {
  276. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  277. }
  278. },
  279. created() {
  280. this.getList()
  281. this.getDownList()
  282. this.getButtons()
  283. },
  284. methods: {
  285. getButtons() {
  286. const Edit = 'SystemConsumption'
  287. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  288. this.isRoleEdit = isRoleEdit
  289. },
  290. getDownList() {
  291. GetDataByNames(this.requestParams).then(response => {
  292. this.operationTypeList = response.data.getDictByName.list
  293. this.livestockList = response.data.getCowclassListEnable.list
  294. })
  295. },
  296. handleBefore() {
  297. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  298. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  299. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  300. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  301. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  302. this.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  303. this.table.getdataListParm.parammaps.stopTime = parseTime(stop, '{y}-{m}-{d}')
  304. this.$forceUpdate()
  305. }
  306. },
  307. handleNext() {
  308. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  309. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  310. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  311. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  312. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  313. this.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  314. this.table.getdataListParm.parammaps.stopTime = parseTime(stop, '{y}-{m}-{d}')
  315. this.$forceUpdate()
  316. }
  317. },
  318. getList() {
  319. this.table.listLoading = true
  320. GetDataByName(this.table.getdataListParm).then(response => {
  321. console.log('table数据', response.data.list)
  322. if (response.data.list !== null) {
  323. this.table.list = response.data.list
  324. this.table.pageNum = response.data.pageNum
  325. this.table.pageSize = response.data.pageSize
  326. this.table.total = response.data.total
  327. } else {
  328. this.table.list = []
  329. }
  330. setTimeout(() => {
  331. this.table.listLoading = false
  332. }, 100)
  333. })
  334. },
  335. handleSearch() {
  336. console.log('点击了查询')
  337. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  338. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  339. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  340. } else {
  341. this.table.getdataListParm.parammaps.inputDatetime = ''
  342. this.table.getdataListParm.parammaps.startTime = ''
  343. this.table.getdataListParm.parammaps.stopTime = ''
  344. }
  345. this.table.getdataListParm.offset = 1
  346. this.getList()
  347. },
  348. handleRefresh() {
  349. console.log('点击了重置')
  350. this.table.getdataListParm.parammaps.inputDatetime = ''
  351. this.table.getdataListParm.parammaps.startTime = ''
  352. this.table.getdataListParm.parammaps.stopTime = ''
  353. this.table.getdataListParm.parammaps.feedid = ''
  354. this.table.getdataListParm.parammaps.cowclassid = ''
  355. this.table.getdataListParm.parammaps.ischarge = ''
  356. this.table.getdataListParm.parammaps.usetype = ''
  357. this.table.getdataListParm.parammaps.feedname = ''
  358. this.table.getdataListParm.parammaps.cowclassid = ''
  359. },
  360. // 操作类型
  361. changeUsetype(item) {
  362. console.log(item)
  363. if (item == '损耗') {
  364. console.log(item)
  365. this.create.createTemp.cowclassid = ''
  366. this.create.createTemp.cowclass = ''
  367. }
  368. },
  369. tableFeedNameSearch(queryString, cb) {
  370. this.create.getfeedNameParm.parammaps['feedname'] = queryString
  371. GetDataByName(this.create.getfeedNameParm).then(response => {
  372. console.log('模糊查询搜索data', response.data.list)
  373. if (response.data.list == null) {
  374. cb([])
  375. } else {
  376. cb(response.data.list)
  377. }
  378. })
  379. },
  380. handleSelectTableFeedName(item) {
  381. this.table.getdataListParm.parammaps.feedid = item.feedid
  382. },
  383. // 饲料名称
  384. feedNameSearch(queryString, cb) {
  385. this.create.getfeedNameParm.parammaps['feedname'] = queryString
  386. GetDataByName(this.create.getfeedNameParm).then(response => {
  387. console.log('模糊查询搜索data', response.data.list)
  388. if (response.data.list == null) {
  389. cb([])
  390. } else {
  391. cb(response.data.list)
  392. }
  393. })
  394. },
  395. handleSelectFeedName(item) {
  396. console.log(item)
  397. this.create.createTemp.feedname = item.feedname
  398. this.create.createTemp.feedid = item.feedid
  399. this.create.createTemp.price = item.price
  400. this.create.createTemp.pcpde = item.pcpde
  401. this.create.createTemp.repertoryweight = item.stockweight
  402. },
  403. blurFeedName() {
  404. this.create.createTemp.feedname = ''
  405. this.create.createTemp.feedid = ''
  406. this.create.createTemp.price = ''
  407. this.create.createTemp.pcpde = ''
  408. this.create.createTemp.repertoryweight = ''
  409. },
  410. // 牲畜类别
  411. changeLivestock(item) {
  412. this.create.createTemp.cowclass = this.livestockList.find(obj => obj.id == item).classname
  413. },
  414. resetCreateTemp() {
  415. this.create.createTemp = {
  416. pastureid: Cookies.get('pastureid'), usedate: parseTime(new Date(), '{y}-{m}-{d}'), feedid: '', feedname: '', cowclassid: '', cowclass: '', usetype: '', operateweight: '', repertoryweight: '', createemp: Cookies.get('employename'), remark: '', price: '', operator: Cookies.get('employename')
  417. }
  418. },
  419. handleCreate() {
  420. console.log('点击了新增')
  421. this.create.dialogStatus = 'create'
  422. this.create.dialogFormVisible = true
  423. this.$nextTick(() => {
  424. this.resetCreateTemp()
  425. this.$refs.createTemp.resetFields()
  426. })
  427. },
  428. createData() {
  429. console.log('点击了新增保存')
  430. this.$refs['createTemp'].validate(valid => {
  431. if (valid) {
  432. this.isokDisable = true
  433. setTimeout(() => {
  434. this.isokDisable = false
  435. }, 1000)
  436. if (this.create.createTemp.usetype == '人工用料') {
  437. if (this.create.createTemp.cowclassid == '') {
  438. this.$message({ type: 'error', message: '请选择牲畜类别', duration: 2000 })
  439. return false
  440. }
  441. }
  442. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  443. // 操作重量
  444. if (this.create.createTemp.operateweight == 0) {
  445. this.$message({ type: 'error', message: '操作重量请输入自然数并保留两位小数', duration: 2000 })
  446. return false
  447. } else {
  448. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  449. this.$message({ type: 'error', message: '操作重量请输入自然数并保留两位小数', duration: 2000 })
  450. return false
  451. }
  452. }
  453. this.requestParam.common = { 'returnmap': '0' }
  454. this.requestParam.data = []
  455. this.requestParam.data[0] = { 'name': 'insertFeeduse', 'type': 'e', 'parammaps': {
  456. 'pastureid': this.create.createTemp.pastureid,
  457. 'usedate': this.create.createTemp.usedate,
  458. 'feedid': this.create.createTemp.feedid,
  459. 'feedname': this.create.createTemp.feedname,
  460. 'cowclassid': this.create.createTemp.cowclassid,
  461. 'cowclass': this.create.createTemp.cowclass,
  462. 'usetype': this.create.createTemp.usetype,
  463. 'operateweight': this.create.createTemp.operateweight,
  464. 'repertoryweight': this.create.createTemp.repertoryweight,
  465. 'createemp': this.create.createTemp.createemp,
  466. 'remark': this.create.createTemp.remark,
  467. 'price': this.create.createTemp.price
  468. }}
  469. this.requestParam.data[1] = { 'name': 'insertFeedstorageUse', 'type': 'e', 'parammaps': {
  470. 'pastureid': this.create.createTemp.pastureid,
  471. 'feedid': this.create.createTemp.feedid,
  472. 'operateweight': this.create.createTemp.operateweight,
  473. 'fname': this.create.createTemp.feedname,
  474. 'pcpde': this.create.createTemp.pcpde,
  475. 'price': this.create.createTemp.price
  476. }}
  477. ExecDataByConfig(this.requestParam).then(response => {
  478. if (response.msg === 'fail') {
  479. failproccess(response, this.$notify)
  480. } else {
  481. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  482. this.create.dialogFormVisible = false
  483. this.getList()
  484. }
  485. })
  486. }
  487. })
  488. },
  489. handleSee(row) {
  490. this.$nextTick(() => {
  491. this.$refs.createTemp.resetFields()
  492. })
  493. this.create.dialogStatus = 'see'
  494. this.create.dialogFormVisible = true
  495. if (row.cowclassid == -1) {
  496. row.cowclassid = ''
  497. row.cowclass = ''
  498. }
  499. this.create.createTemp = Object.assign({}, row)
  500. },
  501. handleRowDelete(row) {
  502. console.log('点击了行内删除')
  503. },
  504. // 导出
  505. handleExport(item) {
  506. if (item == 1) {
  507. console.log('点击了导出模板')
  508. } else {
  509. console.log('点击了导出数据')
  510. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  511. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  512. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  513. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  514. } else {
  515. this.download.getdataListParm.parammaps.inputDatetime = ''
  516. this.download.getdataListParm.parammaps.startTime = ''
  517. this.download.getdataListParm.parammaps.stopTime = ''
  518. }
  519. GetDataByName(this.download.getdataListParm).then(response => {
  520. if (response.data.list !== null) {
  521. this.download.list = response.data.list
  522. } else {
  523. this.download.list = []
  524. }
  525. var excelDatas = [
  526. {
  527. tHeader: ['出库日期', '操作类型', '牲畜类别', '饲料名称', '操作重量(kg)', '备注', '操作人'],
  528. filterVal: ['usedate', 'usetype', 'cowclass', 'feedname', 'operateweight', 'remark', 'createemp'],
  529. tableDatas: this.download.list,
  530. sheetName: 'Sheet1'
  531. }
  532. ]
  533. json2excel(excelDatas, '人工用量', true, 'xlsx')
  534. })
  535. }
  536. },
  537. beforeImport(file) {
  538. const isLt2M = file.size / 1024 / 1024 < 2
  539. if (!isLt2M) {
  540. this.$message.error('上传文件大小不能超过 2MB!')
  541. }
  542. return isLt2M
  543. },
  544. handleImportSuccess(res, file) {
  545. this.getList()
  546. if (res.msg === 'ok') {
  547. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  548. if (res.data.err_count > 0) {
  549. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  550. import('@/vendor/Export2Excel').then(excel => {
  551. const list1 = res.data.result
  552. const tHeader = [
  553. '出库日期', '操作类型', '牲畜类别', '饲料名称', '操作重量(kg)', '备注', '操作人', '错误信息'
  554. ]
  555. const filterVal = [
  556. '出库日期', '操作类型', '牲畜类别', '饲料名称', '操作重量(kg)', '备注', '操作人', 'error_msg'
  557. ]
  558. const data1 = this.formatJson(filterVal, list1)
  559. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '人工用量导入报错信息', autoWidth: true, bookType: 'xlsx' })
  560. })
  561. }
  562. } else {
  563. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  564. }
  565. },
  566. formatJson(filterVal, jsonData) {
  567. return jsonData.map(v =>
  568. filterVal.map(j => {
  569. if (j === 'timestamp') {
  570. return parseTime(v[j])
  571. } else {
  572. return v[j]
  573. }
  574. })
  575. )
  576. }
  577. }
  578. }
  579. </script>
  580. <style lang="scss" scoped>
  581. .search{margin-top:10px;}
  582. .table{margin-top:10px;}
  583. </style>
  584. <style lang="scss">
  585. .typeSelect span .el-popover__reference .el-input--suffix {
  586. .el-input__inner{
  587. height:40px !important;
  588. }
  589. }
  590. </style>