76827304dca90282f737360e019de34ea2c1f80e.svn-base 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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.providerid" filterable placeholder="请选择供应商" class="filter-item" style="width: 150px;" clearable>
  21. <el-option v-for="item in supplierList" :key="item.id" :label="item.providerName" :value="item.id" />
  22. </el-select>
  23. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  24. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  25. </div>
  26. <div class="table">
  27. <el-table
  28. :key="table.tableKey"
  29. v-loading="table.listLoading"
  30. element-loading-text="给我一点时间"
  31. :data="table.list"
  32. border
  33. fit
  34. highlight-current-row
  35. style="width: 100%;"
  36. :row-style="rowStyle"
  37. :cell-style="cellStyle"
  38. class="elTable table-fixed"
  39. >
  40. <el-table-column label="序号" align="center" type="index" width="50px">
  41. <template slot-scope="scope">
  42. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="合同编号" min-width="130px" align="center">
  46. <template slot-scope="scope">
  47. <span>{{ scope.row.contractcode }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="供应商" min-width="130px" align="center">
  51. <template slot-scope="scope">
  52. <span>{{ scope.row.providername }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="录入日期" min-width="110px" align="center">
  56. <template slot-scope="scope">
  57. <span>{{ scope.row.operatetime }}</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="启用" min-width="110px" align="center">
  61. <template slot-scope="scope">
  62. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  66. <template slot-scope="{row}">
  67. <el-button class="miniPrimary" @click="handleSee(row)">查看</el-button>
  68. <el-button class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  69. <el-button class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  74. </div>
  75. <!-- 新增 -->
  76. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  77. <div class="app-add">
  78. <el-form ref="createTemp" :rules="create.rules" :model="create.createTemp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto">
  79. <el-row>
  80. <el-col :span="8">
  81. <el-form-item label="合同编号:" prop="contractcode">
  82. <el-input ref="contractcode" v-model="create.createTemp.contractcode" class="filter-item" placeholder="合同编号" type="text" :disabled="create.dialogStatus !== 'create'" />
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="8">
  86. <el-form-item label="供应商:" prop="providerid">
  87. <el-select v-model="create.createTemp.providerid" filterable placeholder="请选择供应商" class="filter-item" style="width: 100%;" :disabled="create.dialogStatus !== 'create'" @change="changeSupplier">
  88. <el-option v-for="item in supplierList" :key="item.id" :label="item.providerName" :value="item.id" />
  89. </el-select>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="8">
  93. <el-form-item label="录入日期:" prop="operatetime">
  94. <el-date-picker v-model="create.createTemp.operatetime" class="filter-item" type="date" placeholder="录入日期" :disabled="create.dialogStatus==='see'" :clearable="false" />
  95. </el-form-item>
  96. </el-col>
  97. </el-row>
  98. <el-row>
  99. <el-col :span="8">
  100. <el-form-item label="添加饲料:" prop="feedid">
  101. <el-select v-model="create.createTemp.feedid" filterable placeholder="请选择饲料" class="filter-item" style="width: 100%;" :disabled="create.dialogStatus==='see'" @change="changeFeedNameAdd">
  102. <el-option v-for="item in feedNameAddList" :key="item.id" :label="item.fname" :value="item.id" />
  103. </el-select>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="8">
  107. <el-form-item label="是否启用:" prop="enable">
  108. <el-switch v-model="create.createTemp.enable" :disabled="create.dialogStatus==='see'" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  109. </el-form-item>
  110. </el-col>
  111. </el-row>
  112. </el-form>
  113. <el-table
  114. :key="create.tableKey"
  115. v-loading="create.listLoading"
  116. element-loading-text="给我一点时间"
  117. :data="create.list"
  118. border
  119. fit
  120. highlight-current-row
  121. style="width: 100%;margin-bottom: 50px;"
  122. :row-style="rowStyle"
  123. :cell-style="cellStyle"
  124. class="elTable table-fixed"
  125. >
  126. <el-table-column label="饲料名称" min-width="130px" align="center">
  127. <template slot-scope="scope">
  128. <span>{{ scope.row.feedname }}</span>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="饲料价格" min-width="130px" align="center">
  132. <template slot-scope="scope">
  133. <el-input v-if="create.dialogStatus !=='see'" ref="input" v-model="scope.row.price" type="number" :step="0.01" placeholder="最多两位小数" style="width:80%;padding:10px 0;" />
  134. <span v-else> {{ scope.row.price }}</span>
  135. </template>
  136. </el-table-column>
  137. <el-table-column v-if="create.dialogStatus !=='see'" label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
  138. <template slot-scope="{row}">
  139. <a class="smallDanger" @click="handleFeedDelete(row)">删除</a>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <div slot="footer" class="dialog-footer">
  144. <el-button class="cancelClose" @click="create.dialogFormVisible = false; ">关闭</el-button>
  145. <el-button v-if="create.dialogStatus !== 'see'" class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  146. </div>
  147. </div>
  148. </el-dialog>
  149. </div>
  150. </template>
  151. <script>
  152. import { GetDataByName, GetDataByNames, checkButtons, ExecDataByConfig, failproccess } from '@/api/common'
  153. import Pagination from '@/components/Pagination'
  154. import { parseTime, json2excel } from '@/utils/index.js'
  155. import { MessageBox } from 'element-ui'
  156. import Cookies from 'js-cookie'
  157. import { getToken } from '@/utils/auth'
  158. export default {
  159. name: 'FeedContract',
  160. components: { Pagination },
  161. data() {
  162. return {
  163. isRoleEdit: [],
  164. requestParams: [
  165. { name: 'getProviderListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  166. { name: 'getFeedListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  167. ],
  168. supplierList: [], // 供应商
  169. feedNameAddList: [], // 饲料名称
  170. table: {
  171. getdataListParm: {
  172. name: 'getBigContractList',
  173. page: 1,
  174. offset: 1,
  175. pagecount: 10,
  176. returntype: 'Map',
  177. parammaps: {
  178. pastureid: Cookies.get('pastureid'),
  179. inputDatetime: '',
  180. startTime: '',
  181. stopTime: ''
  182. }
  183. },
  184. tableKey: 0,
  185. list: [],
  186. total: 0,
  187. listLoading: true
  188. },
  189. textMap: {
  190. create: '新增合同',
  191. update: '编辑合同',
  192. see: '查看合同'
  193. },
  194. create: {
  195. dialogFormVisible: false,
  196. dialogStatus: '',
  197. createTemp: {
  198. pastureid: Cookies.get('pastureid'), 'providerid': '', 'providername': '', 'emp': Cookies.get('employename'), 'enable': 1, 'operatetime': parseTime(new Date(), '{y}-{m}-{d}')
  199. },
  200. rules: {
  201. contractcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  202. providerid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  203. },
  204. getdataListParm: {
  205. name: 'getContractList',
  206. page: 1,
  207. offset: 1,
  208. pagecount: 10,
  209. returntype: 'Map',
  210. parammaps: {}
  211. },
  212. listLoading: false,
  213. tableKey: 0,
  214. list: []
  215. },
  216. requestParam: {},
  217. download: {
  218. getdataListParm: {
  219. name: 'getBigContractList',
  220. page: 1,
  221. offset: 1,
  222. pagecount: 0,
  223. returntype: 'Map',
  224. parammaps: {
  225. pastureid: Cookies.get('pastureid'),
  226. inputDatetime: '',
  227. startTime: '',
  228. stopTime: ''
  229. }
  230. },
  231. list: []
  232. },
  233. isokDisable: false,
  234. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  235. cellStyle: { padding: 0 + 'px' }
  236. }
  237. },
  238. computed: {
  239. // 设置请求头
  240. headers() {
  241. return {
  242. token: getToken()
  243. }
  244. },
  245. uploadData() {
  246. return {
  247. name: '颛孙洋洋-饲料合同',
  248. importParams: '合同编号, 供应商, 饲料名称, 饲料价格(元), 录入日期',
  249. sheetname: 'SheetJS'
  250. }
  251. },
  252. // 设置上传地址
  253. uploadExcelUrl() {
  254. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  255. }
  256. },
  257. created() {
  258. this.getButtons()
  259. this.getDownList()
  260. this.getList()
  261. },
  262. methods: {
  263. getButtons() {
  264. const Edit = 'FeedContract'
  265. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  266. this.isRoleEdit = isRoleEdit
  267. },
  268. getDownList() {
  269. GetDataByNames(this.requestParams).then(response => {
  270. this.supplierList = response.data.getProviderListEnable.list
  271. this.feedNameAddList = response.data.getFeedListEnable.list
  272. })
  273. },
  274. handleBefore() {
  275. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  276. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  277. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  278. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  279. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  280. this.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  281. this.table.getdataListParm.parammaps.stopTime = parseTime(stop, '{y}-{m}-{d}')
  282. this.$forceUpdate()
  283. this.getList()
  284. }
  285. },
  286. handleNext() {
  287. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  288. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  289. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  290. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  291. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  292. this.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  293. this.table.getdataListParm.parammaps.stopTime = parseTime(stop, '{y}-{m}-{d}')
  294. this.$forceUpdate()
  295. }
  296. },
  297. getList() {
  298. this.table.listLoading = true
  299. GetDataByName(this.table.getdataListParm).then(response => {
  300. console.log('table数据', response.data.list)
  301. if (response.data.list !== null) {
  302. this.table.list = response.data.list
  303. this.table.pageNum = response.data.pageNum
  304. this.table.pageSize = response.data.pageSize
  305. this.table.total = response.data.total
  306. } else {
  307. this.table.list = []
  308. }
  309. setTimeout(() => {
  310. this.table.listLoading = false
  311. }, 100)
  312. })
  313. },
  314. handleSearch() {
  315. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  316. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  317. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  318. } else {
  319. this.table.getdataListParm.parammaps.inputDatetime = ''
  320. this.table.getdataListParm.parammaps.startTime = ''
  321. this.table.getdataListParm.parammaps.stopTime = ''
  322. }
  323. this.table.getdataListParm.offset = 1
  324. this.getList()
  325. },
  326. handleRefresh() {
  327. this.table.getdataListParm.parammaps.inputDatetime = ''
  328. this.table.getdataListParm.parammaps.startTime = ''
  329. this.table.getdataListParm.parammaps.stopTime = ''
  330. this.table.getdataListParm.parammaps.providerid = ''
  331. },
  332. resetCreateTemp() {
  333. this.create.createTemp = {
  334. pastureid: Cookies.get('pastureid'), 'providerid': '', 'providername': '', 'emp': Cookies.get('employename'), 'enable': 1, 'operatetime': parseTime(new Date(), '{y}-{m}-{d}')
  335. }
  336. this.create.list = []
  337. },
  338. handleCreate() {
  339. console.log('点击了新增')
  340. this.resetCreateTemp()
  341. this.create.dialogStatus = 'create'
  342. this.create.dialogFormVisible = true
  343. },
  344. // 供应商
  345. changeSupplier(item) {
  346. this.create.createTemp.providername = this.supplierList.find(obj => obj.id == item).providerName
  347. },
  348. // 新增饲料
  349. changeFeedNameAdd(item) {
  350. var obj = {}
  351. obj.feedid = item
  352. obj.feedname = this.feedNameAddList.find(obj => obj.id == item).fname
  353. obj.pastureid = this.feedNameAddList.find(obj => obj.id == item).pastureid
  354. obj.price = ''
  355. obj.myId = (new Date()).valueOf()
  356. for (let i = 0; i < this.create.list.length; i++) {
  357. if (this.create.list[i].feedid == item) {
  358. this.$message({ type: 'warning', message: '添加饲料不可重复', duration: 2000 })
  359. return false
  360. }
  361. }
  362. this.create.list.push(obj)
  363. },
  364. handleFeedDelete(row) {
  365. for (let i = 0; i < this.create.list.length; i++) {
  366. console.log(this.create.list[i])
  367. if (this.create.list[i].myId === row.myId) {
  368. var listAddIndex = this.create.list.indexOf(this.create.list[i])
  369. }
  370. if (listAddIndex > -1) {
  371. this.create.list.splice(listAddIndex, 1)
  372. return
  373. }
  374. }
  375. },
  376. createData() {
  377. console.log('点击了新增保存')
  378. this.$refs['createTemp'].validate(valid => {
  379. if (valid) {
  380. this.isokDisable = true
  381. setTimeout(() => {
  382. this.isokDisable = false
  383. }, 1000)
  384. console.log(this.create.list.length)
  385. if (this.create.list.length == 0) {
  386. this.$message({ type: 'warning', message: '请添加饲料', duration: 2000 })
  387. return false
  388. }
  389. const rulesPrice = /^\d+(\.\d{1,2})?$/
  390. for (let i = 0; i < this.create.list.length; i++) {
  391. if (this.create.list[i].price == '') {
  392. this.$message({ type: 'warning', message: '饲料价格不可为空', duration: 2000 })
  393. return false
  394. }
  395. if (!rulesPrice.test(parseFloat(this.create.list[i].price))) {
  396. this.$message({ type: 'warning', message: '饲料价格最多保留两位小数', duration: 2000 })
  397. return false
  398. }
  399. }
  400. this.create.createTemp.operatetime = parseTime(this.create.createTemp.operatetime, '{y}-{m}-{d}')
  401. this.requestParam.common = { 'returnmap': '0' }
  402. this.requestParam.data = []
  403. this.requestParam.data[0] = { 'name': 'insertBigContract', 'type': 'e', 'parammaps': {
  404. 'pastureid': this.create.createTemp.pastureid,
  405. 'contractcode': this.create.createTemp.contractcode,
  406. 'providerid': this.create.createTemp.providerid,
  407. 'providername': this.create.createTemp.providername,
  408. 'emp': this.create.createTemp.emp,
  409. 'enable': this.create.createTemp.enable,
  410. 'operatetime': this.create.createTemp.operatetime
  411. }}
  412. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.create.list }}
  413. this.requestParam.data[1].children = []
  414. this.requestParam.data[1].children[0] = { 'name': 'insertContract', 'type': 'e', 'parammaps': {
  415. pastureid: '@insertSpotList.pastureid',
  416. bigid: '@insertBigContract.LastInsertId',
  417. feedid: '@insertSpotList.feedid',
  418. feedname: '@insertSpotList.feedname',
  419. price: '@insertSpotList.price'
  420. }}
  421. ExecDataByConfig(this.requestParam).then(response => {
  422. if (response.msg == 'fail') {
  423. const contractcode = new RegExp("key 'contractcode'")
  424. if (contractcode.test(response.data)) {
  425. this.$message({ type: 'error', message: '该合同已存在,不可重复生成', duration: 2000 })
  426. } else {
  427. failproccess(response, this.$notify)
  428. }
  429. } else {
  430. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  431. this.create.dialogFormVisible = false
  432. this.getList()
  433. }
  434. })
  435. }
  436. })
  437. },
  438. handleUpdate(row) {
  439. console.log('点击了编辑')
  440. this.create.dialogStatus = 'update'
  441. this.create.dialogFormVisible = true
  442. this.create.createTemp = Object.assign({}, row)
  443. this.create.getdataListParm.parammaps.pastureid = row.pastureid
  444. this.create.getdataListParm.parammaps.id = row.id
  445. this.getSeeList()
  446. },
  447. updateData() {
  448. console.log('点击了编辑保存')
  449. this.$refs['createTemp'].validate(valid => {
  450. if (valid) {
  451. this.isokDisable = true
  452. setTimeout(() => {
  453. this.isokDisable = false
  454. }, 1000)
  455. console.log(this.create.list.length)
  456. if (this.create.list.length == 0) {
  457. this.$message({ type: 'warning', message: '请添加饲料', duration: 2000 })
  458. return false
  459. }
  460. const rulesPrice = /^\d+(\.\d{1,2})?$/
  461. for (let i = 0; i < this.create.list.length; i++) {
  462. if (this.create.list[i].price == '') {
  463. this.$message({ type: 'warning', message: '饲料价格不可为空', duration: 2000 })
  464. return false
  465. }
  466. if (!rulesPrice.test(parseFloat(this.create.list[i].price))) {
  467. this.$message({ type: 'warning', message: '饲料价格最多保留两位小数', duration: 2000 })
  468. return false
  469. }
  470. }
  471. this.create.createTemp.operatetime = parseTime(this.create.createTemp.operatetime, '{y}-{m}-{d}')
  472. this.requestParam.common = { 'returnmap': '0' }
  473. this.requestParam.data = []
  474. this.requestParam.data[0] = { 'name': 'updateBigContract', 'type': 'e', 'parammaps': {
  475. 'pastureid': this.create.createTemp.pastureid,
  476. 'id': this.create.createTemp.id,
  477. 'operatetime': this.create.createTemp.operatetime,
  478. 'enable': this.create.createTemp.enable
  479. }}
  480. this.requestParam.data[1] = { 'name': 'deleteContract', 'type': 'e', 'parammaps': {
  481. 'pastureid': this.create.createTemp.pastureid,
  482. 'id': this.create.createTemp.id
  483. }}
  484. this.requestParam.data[2] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.create.list }}
  485. this.requestParam.data[2].children = []
  486. this.requestParam.data[2].children[0] = { 'name': 'insertContract', 'type': 'e', 'parammaps': {
  487. pastureid: '@insertSpotList.pastureid',
  488. bigid: this.create.createTemp.id,
  489. feedid: '@insertSpotList.feedid',
  490. feedname: '@insertSpotList.feedname',
  491. price: '@insertSpotList.price'
  492. }}
  493. ExecDataByConfig(this.requestParam).then(response => {
  494. if (response.msg === 'fail') {
  495. failproccess(response, this.$notify)
  496. } else {
  497. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  498. this.create.dialogFormVisible = false
  499. this.getList()
  500. }
  501. })
  502. }
  503. })
  504. },
  505. handleSee(row) {
  506. console.log('点击了查看')
  507. this.create.dialogStatus = 'see'
  508. this.create.dialogFormVisible = true
  509. this.create.createTemp = Object.assign({}, row)
  510. this.create.getdataListParm.parammaps.pastureid = row.pastureid
  511. this.create.getdataListParm.parammaps.id = row.id
  512. this.getSeeList()
  513. },
  514. getSeeList() {
  515. this.create.listLoading = true
  516. GetDataByName(this.create.getdataListParm).then(response => {
  517. console.log('查看table数据', response.data.list)
  518. if (response.data.list !== null) {
  519. this.create.list = response.data.list
  520. } else {
  521. this.create.list = []
  522. }
  523. setTimeout(() => {
  524. this.create.listLoading = false
  525. }, 100)
  526. })
  527. },
  528. handleRowDelete(row) {
  529. MessageBox.confirm('是否确认删除此信息?', {
  530. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  531. }).then(() => {
  532. console.log('点击了删除')
  533. this.requestParam.common = { 'returnmap': '0' }
  534. this.requestParam.data = []
  535. this.requestParam.data[0] = { 'name': 'deleteBigContract', 'type': 'e', 'parammaps': {
  536. 'pastureid': row.pastureid,
  537. 'id': row.id
  538. }}
  539. this.requestParam.data[1] = { 'name': 'deleteContract', 'type': 'e', 'parammaps': {
  540. 'pastureid': row.pastureid,
  541. 'id': row.id
  542. }}
  543. ExecDataByConfig(this.requestParam).then(response => {
  544. if (response.msg === 'fail') {
  545. failproccess(response, this.$notify)
  546. } else {
  547. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  548. this.getList()
  549. }
  550. })
  551. }).catch(() => {
  552. this.$message({ type: 'info', message: '已取消删除' })
  553. })
  554. },
  555. handleExport(item) {
  556. if (item == 1) {
  557. console.log('点击了导出模板')
  558. } else {
  559. console.log('点击了导出数据')
  560. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  561. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  562. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  563. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  564. } else {
  565. this.download.getdataListParm.parammaps.inputDatetime = ''
  566. this.download.getdataListParm.parammaps.startTime = ''
  567. this.download.getdataListParm.parammaps.stopTime = ''
  568. }
  569. GetDataByName(this.download.getdataListParm).then(response => {
  570. if (response.data.list !== null) {
  571. this.download.list = response.data.list
  572. } else {
  573. this.download.list = []
  574. }
  575. var excelDatas = [
  576. {
  577. tHeader: ['合同编号', '供应商', '饲料名称', '饲料价格(元)', '录入日期'],
  578. filterVal: ['contractcode', 'providername', 'feedname', 'price', 'operatetime'],
  579. tableDatas: this.download.list,
  580. sheetName: 'Sheet1'
  581. }
  582. ]
  583. json2excel(excelDatas, '饲料合同', true, 'xlsx')
  584. })
  585. }
  586. },
  587. beforeImport(file) {
  588. const isLt2M = file.size / 1024 / 1024 < 2
  589. if (!isLt2M) {
  590. this.$message.error('上传文件大小不能超过 2MB!')
  591. }
  592. return isLt2M
  593. },
  594. handleImportSuccess(res, file) {
  595. this.getList()
  596. if (res.msg === 'ok') {
  597. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  598. if (res.data.err_count > 0) {
  599. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  600. import('@/vendor/Export2Excel').then(excel => {
  601. const list1 = res.data.result
  602. const tHeader = [
  603. '合同编号', '供应商', '饲料名称', '饲料价格(元)', '录入日期', '错误信息'
  604. ]
  605. const filterVal = [
  606. '合同编号', '供应商', '饲料名称', '饲料价格(元)', '录入日期', 'error_msg'
  607. ]
  608. const data1 = this.formatJson(filterVal, list1)
  609. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '入库管理导入报错信息', autoWidth: true, bookType: 'xlsx' })
  610. })
  611. }
  612. } else {
  613. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  614. }
  615. },
  616. formatJson(filterVal, jsonData) {
  617. return jsonData.map(v =>
  618. filterVal.map(j => {
  619. if (j === 'timestamp') {
  620. return parseTime(v[j])
  621. } else {
  622. return v[j]
  623. }
  624. })
  625. )
  626. }
  627. }
  628. }
  629. </script>
  630. <style lang="scss" scoped>
  631. .search{margin-top:10px;}
  632. .table{margin-top:10px;}
  633. </style>
  634. <style>
  635. .inputDatetime .el-range-separator{ padding: 0; margin: 0 10px; }
  636. </style>