0e0bc6e7255d015e78b3535869a2880dc0530f45.svn-base 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  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.feedid" filterable placeholder="饲料名称" class="filter-item" style="width: 150px;" clearable>
  8. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  9. </el-select>
  10. <el-select v-model="table.getdataListParm.parammaps.providerid" placeholder="供应商" class="filter-item" style="width: 150px;" clearable>
  11. <el-option v-for="item in supplierList" :key="item.id" :label="item.providerName" :value="item.id" />
  12. </el-select>
  13. <el-select v-model="table.getdataListParm.parammaps.islaid" placeholder="是否入库" class="filter-item" style="width: 150px;" clearable>
  14. <el-option v-for="item in islaidList" :key="item.id" :label="item.name" :value="item.name" />
  15. </el-select>
  16. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  17. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  18. </div>
  19. <div class="operation">
  20. <el-button class="success" icon="el-icon-plus" @click="handleCreate">新增入库单</el-button>
  21. <el-upload style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  22. <el-button class="import" icon="el-icon-download" style="float: right;">导入</el-button>
  23. </el-upload>
  24. <el-dropdown style="float: right;margin-right: 10px;">
  25. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  26. <el-dropdown-menu slot="dropdown">
  27. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  28. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  29. </el-dropdown-menu>
  30. </el-dropdown>
  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. >
  46. <el-table-column label="序号" align="center" type="index" width="50px">
  47. <template slot-scope="scope">
  48. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="入库日期" min-width="90px" align="center">
  52. <template slot-scope="scope">
  53. <span>{{ scope.row.laiddate }}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="饲料名称" min-width="90px" align="center">
  57. <template slot-scope="scope">
  58. <span>{{ scope.row.feedname }}</span>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="供应商" min-width="90px" align="center">
  62. <template slot-scope="scope">
  63. <span>{{ scope.row.providername }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="入库重量(kg)" min-width="90px" align="center">
  67. <template slot-scope="scope">
  68. <span>{{ scope.row.operateweight }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="总价(元)" min-width="90px" align="center">
  72. <template slot-scope="scope">
  73. <span>{{ scope.row.sumprice }}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="批号" min-width="90px" align="center">
  77. <template slot-scope="scope">
  78. <span>{{ scope.row.pcpde }}</span>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="备注" min-width="90px" align="center">
  82. <template slot-scope="scope">
  83. <span>{{ scope.row.remark }}</span>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="是否入库" min-width="90px" align="center">
  87. <template slot-scope="scope">
  88. <span>{{ scope.row.islaid }}</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="创建人" min-width="90px" align="center">
  92. <template slot-scope="scope">
  93. <span>{{ scope.row.createemp }}</span>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="创建日期" min-width="90px" align="center">
  97. <template slot-scope="scope">
  98. <span>{{ scope.row.createdate }}</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  102. <template slot-scope="{row}">
  103. <el-button class="miniSuccess" icon="el-icon-search" @click="handleSee(row)" />
  104. <el-button v-if="row.islaid == '否'" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  109. </div>
  110. <!-- 新增入库单 -->
  111. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  112. <div class="app-add">
  113. <el-form ref="createTemp" :rules="create.rules" :model="create.createTemp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto 50px">
  114. <el-row>
  115. <el-col :span="24">
  116. <h3 style="width: 160px;text-align: right;">基础信息</h3>
  117. </el-col>
  118. </el-row>
  119. <el-row>
  120. <el-col :span="8">
  121. <el-form-item label="入库日期:" prop="laiddate">
  122. <el-date-picker v-model="create.createTemp.laiddate" :disabled="create.dialogStatus=='see'" class="filter-item" type="date" placeholder="入库日期" :clearable="false" :picker-options="create.pickerOptions1" format="yyyy-MM-dd" value-format="yyyy-MM-dd" />
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="8">
  126. <el-form-item label="送货单编号:" prop="wagonnumber">
  127. <el-input ref="wagonnumber" v-model="create.createTemp.wagonnumber" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="送货单编号" type="text" />
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="8">
  131. <el-form-item label="饲料名称:" prop="feedname">
  132. <el-autocomplete
  133. v-model="create.createTemp.feedname"
  134. value-key="fname"
  135. class="inline-input"
  136. :fetch-suggestions="feedNameSearch"
  137. placeholder="请选择饲料名称"
  138. style="width:98%"
  139. :disabled="create.dialogStatus=='see' || create.dialogStatus=='update'"
  140. @select="handleSelectFeedName"
  141. @blur="blurFeedName"
  142. >
  143. <template slot-scope="{ item }">
  144. <span>{{ item.fname }}</span>
  145. </template>
  146. </el-autocomplete>
  147. </el-form-item>
  148. </el-col>
  149. </el-row>
  150. <el-row>
  151. <el-col :span="8">
  152. <el-form-item label="入库重量(kg):" prop="operateweight">
  153. <el-input ref="operateweight" v-model.trim="create.createTemp.operateweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurOperateweight" />
  154. </el-form-item>
  155. </el-col>
  156. <el-col :span="8">
  157. <el-form-item label="供应商:" prop="providerid">
  158. <el-select v-model="create.createTemp.providerid" clearable placeholder="请选择供应商" :disabled="create.dialogStatus=='see'" class="filter-item" style="width: 100%" @change="changeSupplier">
  159. <el-option v-for="item in supplierList" :key="item.id" :label="item.providerName" :value="item.id" />
  160. </el-select>
  161. </el-form-item>
  162. </el-col>
  163. <el-col :span="8">
  164. <el-form-item label="合同编号:" prop="contractcode">
  165. <el-select v-model="create.createTemp.contractcode" clearable placeholder="请选择合同编号" :disabled="create.dialogStatus=='see'" class="filter-item" style="width: 100%" @change="changeContractNo">
  166. <el-option v-for="item in contractNoList" :key="item.id" :label="item.contractcodeCat" :value="item.contractcode" />
  167. </el-select>
  168. </el-form-item>
  169. </el-col>
  170. </el-row>
  171. <el-row>
  172. <el-col :span="24">
  173. <h3 style="width: 160px;text-align: right;">价格信息</h3>
  174. </el-col>
  175. </el-row>
  176. <el-row>
  177. <el-col :span="8">
  178. <el-form-item label="单价(元):" prop="pricenew">
  179. <el-input ref="pricenew" v-model="create.createTemp.pricenew" :disabled="create.createTemp.contractcode !=='' || create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurPricenew" />
  180. </el-form-item>
  181. </el-col>
  182. <el-col :span="8">
  183. <el-form-item label="总价(元):" prop="sumprice">
  184. <el-input ref="sumprice" v-model="create.createTemp.sumprice" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurSumprice" />
  185. </el-form-item>
  186. </el-col>
  187. </el-row>
  188. <el-row>
  189. <el-col :span="24">
  190. <h3 style="width: 160px;text-align: right;">饲料信息</h3>
  191. </el-col>
  192. </el-row>
  193. <el-row>
  194. <el-col :span="8">
  195. <el-form-item label="毛重:" prop="grossweight">
  196. <el-input ref="grossweight" v-model.trim="create.createTemp.grossweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurGrossweight" />
  197. </el-form-item>
  198. </el-col>
  199. <el-col :span="8">
  200. <el-form-item label="皮重:" prop="tareweight">
  201. <el-input ref="tareweight" v-model.trim="create.createTemp.tareweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurTareweight" />
  202. </el-form-item>
  203. </el-col>
  204. <el-col :span="8">
  205. <el-form-item label="许可证号:" prop="licence">
  206. <el-input ref="licence" v-model="create.createTemp.licence" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="许可证号" type="text" />
  207. </el-form-item>
  208. </el-col>
  209. </el-row>
  210. <el-row>
  211. <el-col :span="8">
  212. <el-form-item label="批号:" prop="pcpde">
  213. <el-input ref="pcpde" v-model="create.createTemp.pcpde" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="批号" type="text" />
  214. </el-form-item>
  215. </el-col>
  216. </el-row>
  217. <el-row>
  218. <el-col :span="24">
  219. <h3 style="width: 160px;text-align: right;">操作信息</h3>
  220. </el-col>
  221. </el-row>
  222. <el-row>
  223. <el-col :span="8">
  224. <el-form-item label="创建人:" prop="createemp">
  225. <el-input ref="createemp" v-model="create.createTemp.createemp" class="filter-item" placeholder="创建人" type="text" disabled />
  226. </el-form-item>
  227. </el-col>
  228. <el-col :span="8">
  229. <el-form-item label="创建日期:" prop="createdate">
  230. <el-date-picker v-model="create.createTemp.createdate" class="filter-item" type="date" placeholder="创建日期" disabled />
  231. </el-form-item>
  232. </el-col>
  233. <el-col :span="8">
  234. <el-form-item label="备注:" prop="remark">
  235. <el-input ref="remark" v-model="create.createTemp.remark" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="1-255字符" type="text" />
  236. </el-form-item>
  237. </el-col>
  238. </el-row>
  239. </el-form>
  240. <div slot="footer" class="dialog-footer">
  241. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList(); ">关闭</el-button>
  242. <el-button v-if="create.dialogStatus !== 'see' " class="save" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  243. </div>
  244. </div>
  245. </el-dialog>
  246. <!-- 初始化库存 -->
  247. <el-dialog :title="textMap[initial.dialogStatus]" :visible.sync="initial.dialogFormVisible" :close-on-click-modal="false" width="80%" height="55%">
  248. <div class="app-add" style="height: 100%;margin: 0 auto 60px;">
  249. <div class="operation">
  250. <el-button style="float: left;margin-bottom:10px;" class="success" @click="handleInitialExport">模板下载</el-button>
  251. <el-upload style="float: left;margin-left: 10px;margin-bottom:10px;" action="" :auto-upload="false" accept=".xlsx, .xls" :show-file-list="false" :on-change="handleInitialImport">
  252. <el-button class="success" icon="el-icon-download">导入</el-button>
  253. </el-upload>
  254. </div>
  255. <div class="table">
  256. <el-table
  257. :key="initial.tableKey"
  258. v-loading="initial.listLoading"
  259. element-loading-text="给我一点时间"
  260. :data="initial.list"
  261. border
  262. fit
  263. highlight-current-row
  264. style="width: 100%;"
  265. :row-style="rowStyle"
  266. :cell-style="cellStyle"
  267. class="elTable table-fixed"
  268. >
  269. <el-table-column label="序号" align="center" type="index" width="50px" />
  270. <el-table-column label="饲料名称" min-width="130px" align="center">
  271. <template slot-scope="scope">
  272. <span>{{ scope.row.fname }}</span>
  273. </template>
  274. </el-table-column>
  275. <el-table-column label="库存重量" min-width="130px" align="center">
  276. <template slot-scope="scope">
  277. <el-input v-model="scope.row.stockweight" placeholder="最多两位小数" type="number" :step="0.01" style="width:95%;padding:10px 0;" />
  278. </template>
  279. </el-table-column>
  280. </el-table>
  281. <div slot="footer" class="dialog-footer">
  282. <el-button class="cancelClose" @click="initial.dialogFormVisible = false; ">关闭</el-button>
  283. <el-button class="save" :disabled="isokDisable" @click="initialData()">确认</el-button>
  284. </div>
  285. </div>
  286. </div>
  287. </el-dialog>
  288. </div>
  289. </template>
  290. <script>
  291. import { GetDataByName, GetDataByNames, checkButtons, ExecDataByConfig, failproccess, formatNum } from '@/api/common'
  292. import Pagination from '@/components/Pagination'
  293. import { MessageBox } from 'element-ui'
  294. import Cookies from 'js-cookie'
  295. import { json2excel, parseTime } from '@/utils/index.js'
  296. import axios from 'axios'
  297. import { getToken } from '@/utils/auth'
  298. import xlsx from 'xlsx'
  299. import { upload } from '@/utils/index.js'
  300. export default {
  301. name: 'Warehousing',
  302. components: { Pagination },
  303. data() {
  304. return {
  305. feedNameList: [], // 饲料名称
  306. feedNameAddList: [], // 饲料名称新增
  307. supplierList: [], // 供应商
  308. contractNoList: [], // 合同编号
  309. islaidList: [{ id: 0, name: '是' }, { id: 1, name: '否' }], // 是否入库
  310. requestParams: [
  311. { name: 'getFeedListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  312. { name: 'getProviderListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  313. ],
  314. table: {
  315. getdataListParm: {
  316. name: 'getFeedlaidList',
  317. page: 1,
  318. offset: 1,
  319. pagecount: 10,
  320. returntype: 'Map',
  321. parammaps: {
  322. pastureid: Cookies.get('pastureid'),
  323. inputDatetime: '',
  324. startTime: '',
  325. stopTime: '',
  326. feedid: '',
  327. islaid: '',
  328. providerid: ''
  329. }
  330. },
  331. tableKey: 0,
  332. list: [],
  333. total: 0,
  334. listLoading: true
  335. },
  336. create: {
  337. dialogFormVisible: false,
  338. dialogStatus: '',
  339. pickerOptions1: {
  340. disabledDate(time) {
  341. return time.getTime() > Date.now()// 当天之前的时间可选
  342. }
  343. },
  344. createTemp: {
  345. laiddate: '', feedid: '', feedname: '', operateweight: '', providerid: '', providername: '', startweight: '', priceold: '', contractcode: '', pricenew: '', sumprice: '', grossweight: '', tareweight: '', licence: '', pcpde: '', createemp: '', createdate: '', remark: '', 'wagonnumber': ''
  346. },
  347. rules: {
  348. laiddate: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  349. feedname: [{ type: 'string', required: true, message: '必填', trigger: 'change' }],
  350. pricenew: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  351. },
  352. getdataListParm: {
  353. name: 'getBigContractListEnable',
  354. offset: 0,
  355. pagecount: '',
  356. parammaps: { pastureid: Cookies.get('pastureid') }
  357. },
  358. getfeedNameParm: {
  359. name: 'getFeedListEnableV2',
  360. offset: 0,
  361. pagecount: '',
  362. parammaps: { pastureid: Cookies.get('pastureid') }
  363. }
  364. },
  365. initial: {
  366. dialogFormVisible: false,
  367. dialogStatus: '',
  368. rules: {},
  369. getdataListParm: {
  370. name: 'getinitFeed',
  371. page: 1,
  372. offset: 1,
  373. pagecount: 6,
  374. returntype: 'Map',
  375. parammaps: {
  376. pastureid: Cookies.get('pastureid')
  377. }
  378. },
  379. tableKey: 0,
  380. list: [],
  381. total: 0,
  382. listLoading: true,
  383. character: {
  384. fname: {
  385. text: '饲料名称',
  386. type: String
  387. },
  388. stockweight: {
  389. text: '库存重量',
  390. type: String
  391. }
  392. }
  393. },
  394. textMap: {
  395. create: '新增入库单',
  396. update: '编辑入库单',
  397. see: '查看入库单',
  398. initial: '初始化库存'
  399. },
  400. requestParam: {},
  401. download: {
  402. getdataListParm: {
  403. name: 'getFeedlaidList',
  404. page: 1,
  405. offset: 1,
  406. pagecount: 0,
  407. returntype: 'Map',
  408. parammaps: {
  409. pastureid: Cookies.get('pastureid'),
  410. inputDatetime: '',
  411. startTime: '',
  412. stopTime: '',
  413. feedid: '',
  414. islaid: '',
  415. providerid: ''
  416. }
  417. },
  418. list: []
  419. },
  420. isokDisable: false,
  421. isRoleEdit: [],
  422. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  423. cellStyle: { padding: 0 + 'px' }
  424. }
  425. },
  426. computed: {
  427. // 设置请求头
  428. headers() {
  429. return {
  430. token: getToken()
  431. }
  432. },
  433. uploadData() {
  434. return {
  435. name: 'checkFeed,checkProviderRK,checkcontractcode,checkcontractcodePrice,insertFeedlaidUpload,insertFeedstorageLaidUpload',
  436. importParams: '入库日期,送货单编号,饲料名称,供应商,合同编号,入库重量(kg),单价(元),总价(元),毛重(kg),皮重(kg),许可证号,批号,创建人,备注',
  437. sheetname: 'Sheet1',
  438. // 登录牧场
  439. pastureid: Cookies.get('pastureid'),
  440. // 日期参数
  441. dateParams: '入库日期',
  442. // 必填参数
  443. requiredParams: '入库日期,饲料名称,入库重量(kg),单价(元)',
  444. // 为数值的参数
  445. numParams: '入库重量(kg),单价(元),总价(元),毛重(kg),皮重(kg)'
  446. }
  447. },
  448. // 设置上传地址
  449. uploadExcelUrl() {
  450. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  451. }
  452. },
  453. created() {
  454. this.getButtons()
  455. this.getDownList()
  456. this.getList()
  457. },
  458. methods: {
  459. getButtons() {
  460. const Edit = 'Warehousing'
  461. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  462. this.isRoleEdit = isRoleEdit
  463. },
  464. getDownList() {
  465. GetDataByNames(this.requestParams).then(response => {
  466. this.feedNameList = response.data.getFeedListEnable.list
  467. this.supplierList = response.data.getProviderListEnable.list
  468. })
  469. },
  470. handleBefore() {
  471. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  472. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  473. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  474. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  475. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  476. this.$forceUpdate()
  477. }
  478. },
  479. handleNext() {
  480. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  481. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  482. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  483. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  484. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  485. this.$forceUpdate()
  486. }
  487. },
  488. getList() {
  489. this.table.listLoading = true
  490. GetDataByName(this.table.getdataListParm).then(response => {
  491. console.log('table数据', response.data.list)
  492. if (response.data.list !== null) {
  493. this.table.list = response.data.list
  494. this.table.pageNum = response.data.pageNum
  495. this.table.pageSize = response.data.pageSize
  496. this.table.total = response.data.total
  497. } else {
  498. this.table.list = []
  499. }
  500. setTimeout(() => {
  501. this.table.listLoading = false
  502. }, 100)
  503. })
  504. },
  505. handleSearch() {
  506. // console.log('点击了查询')
  507. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  508. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  509. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  510. } else {
  511. this.table.getdataListParm.parammaps.inputDatetime = ''
  512. this.table.getdataListParm.parammaps.startTime = ''
  513. this.table.getdataListParm.parammaps.stopTime = ''
  514. }
  515. this.table.getdataListParm.offset = 1
  516. this.getList()
  517. },
  518. handleRefresh() {
  519. console.log('点击了重置')
  520. this.table.getdataListParm.parammaps.inputDatetime = ''
  521. this.table.getdataListParm.parammaps.startTime = ''
  522. this.table.getdataListParm.parammaps.stopTime = ''
  523. this.table.getdataListParm.parammaps.feedid = ''
  524. this.table.getdataListParm.parammaps.islaid = ''
  525. this.table.getdataListParm.parammaps.providerid = ''
  526. this.table.getdataListParm.offset = 1
  527. this.getList()
  528. },
  529. resetCreateTemp() {
  530. this.create.createTemp = {
  531. pastureid: Cookies.get('pastureid'), laiddate: parseTime(new Date(), '{y}-{m}-{d}'), feedid: '', feedname: '', operateweight: '', providerid: '', providername: '', startweight: '', priceold: '', contractcode: '', pricenew: '', sumprice: '', grossweight: '', tareweight: '', licence: '', pcpde: '', createemp: Cookies.get('employename'), createdate: parseTime(new Date(), '{y}-{m}-{d}'), remark: '', 'wagonnumber': ''
  532. }
  533. this.contractNoList = []
  534. },
  535. // 供应商
  536. changeSupplier(item) {
  537. console.log(item)
  538. if (item !== '') {
  539. this.create.createTemp.providername = this.supplierList.find(obj => obj.id == item).providerName
  540. } else {
  541. this.create.createTemp.providername = ''
  542. this.create.createTemp.contractcode = ''
  543. this.create.createTemp.pricenew = ''
  544. this.create.createTemp.sumprice = ''
  545. this.contractNoList = []
  546. }
  547. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  548. this.getContractNoList()
  549. }
  550. },
  551. // 合同编号
  552. changeContractNo(item) {
  553. if (item !== '') {
  554. this.create.createTemp.pricenew = this.contractNoList.find(obj => obj.contractcode == item).price
  555. } else {
  556. this.create.createTemp.pricenew = ''
  557. }
  558. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  559. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  560. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  561. }
  562. },
  563. getContractNoList() {
  564. this.create.getdataListParm.parammaps.feedid = this.create.createTemp.feedid
  565. this.create.getdataListParm.parammaps.providerid = this.create.createTemp.providerid
  566. GetDataByName(this.create.getdataListParm).then(response => {
  567. console.log('table数据', response.data.list)
  568. if (response.data.list !== null) {
  569. this.contractNoList = response.data.list
  570. this.create.createTemp.contractcode = ''
  571. this.create.createTemp.pricenew = ''
  572. this.create.createTemp.sumprice = ''
  573. } else {
  574. this.contractNoList = []
  575. this.create.createTemp.contractcode = ''
  576. this.create.createTemp.pricenew = ''
  577. this.create.createTemp.sumprice = ''
  578. }
  579. })
  580. },
  581. feedNameSearch(queryString, cb) {
  582. this.create.getfeedNameParm.parammaps['fname'] = queryString
  583. GetDataByName(this.create.getfeedNameParm).then(response => {
  584. console.log('模糊查询搜索data', response.data.list)
  585. if (response.data.list == null) {
  586. cb([])
  587. } else {
  588. cb(response.data.list)
  589. }
  590. })
  591. },
  592. handleSelectFeedName(item) {
  593. console.log('模糊查询选中值', item)
  594. this.create.createTemp.feedname = item.fname
  595. this.create.createTemp.feedid = item.id
  596. this.create.createTemp.startweight = item.stockweight
  597. this.create.createTemp.priceold = item.price
  598. this.create.createTemp.providerid = ''
  599. this.create.createTemp.providername = ''
  600. this.create.createTemp.contractcode = ''
  601. this.create.createTemp.pricenew = ''
  602. this.create.createTemp.sumprice = ''
  603. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  604. this.getContractNoList()
  605. }
  606. },
  607. blurFeedName() {
  608. this.create.createTemp.feedname = ''
  609. this.create.createTemp.feedid = ''
  610. this.create.createTemp.startweight = ''
  611. this.create.createTemp.priceold = ''
  612. this.create.createTemp.providerid = ''
  613. this.create.createTemp.providername = ''
  614. this.create.createTemp.contractcode = ''
  615. this.create.createTemp.pricenew = ''
  616. this.create.createTemp.sumprice = ''
  617. },
  618. // 入库重量
  619. blurOperateweight() {
  620. // 毛重grossweight皮重tareweight入库重量operateweight
  621. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  622. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight), 2)
  623. }
  624. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  625. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  626. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  627. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  628. }
  629. }
  630. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  631. if (this.create.createTemp.operateweight == '') {
  632. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  633. }
  634. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  635. this.create.createTemp.tareweight = formatNum(this.create.createTemp.grossweight, 2)
  636. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  637. }
  638. }
  639. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  640. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  641. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  642. } else {
  643. this.create.createTemp.sumprice = ''
  644. }
  645. },
  646. // 毛重
  647. blurGrossweight() {
  648. // 毛重grossweight皮重tareweight入库重量operateweight
  649. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  650. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight), 2)
  651. }
  652. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  653. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  654. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  655. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  656. }
  657. }
  658. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  659. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  660. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  661. } else {
  662. this.create.createTemp.sumprice = ''
  663. }
  664. },
  665. // 皮重
  666. blurTareweight() {
  667. // 毛重grossweight皮重tareweight入库重量operateweight
  668. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.tareweight !== '') {
  669. this.create.createTemp.grossweight = formatNum(parseFloat(this.create.createTemp.tareweight) + parseFloat(this.create.createTemp.operateweight), 2)
  670. }
  671. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  672. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  673. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  674. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  675. }
  676. }
  677. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  678. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  679. this.create.createTemp.tareweight = formatNum(this.create.createTemp.grossweight, 2)
  680. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  681. } else {
  682. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  683. }
  684. }
  685. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  686. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  687. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  688. } else {
  689. this.create.createTemp.sumprice = ''
  690. }
  691. },
  692. // 单价
  693. blurPricenew() {
  694. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  695. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  696. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  697. } else {
  698. this.create.createTemp.sumprice = ''
  699. }
  700. },
  701. // 总价
  702. blurSumprice() {
  703. if (this.create.createTemp.sumprice !== '' && this.create.createTemp.pricenew !== '') {
  704. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.sumprice) / parseFloat(this.create.createTemp.pricenew), 2)
  705. } else {
  706. this.create.createTemp.operateweight = ''
  707. }
  708. },
  709. handleCreate() {
  710. console.log('点击了新增入库单')
  711. this.create.dialogStatus = 'create'
  712. this.create.dialogFormVisible = true
  713. this.$nextTick(() => {
  714. this.resetCreateTemp()
  715. this.$refs.createTemp.resetFields()
  716. })
  717. },
  718. createData() {
  719. this.$refs['createTemp'].validate(valid => {
  720. if (valid) {
  721. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  722. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  723. return false
  724. }
  725. if (this.create.createTemp.sumprice.length > 15) {
  726. this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
  727. }
  728. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  729. // 入库重量
  730. if (this.create.createTemp.operateweight !== '') {
  731. if (this.create.createTemp.operateweight == 0) {
  732. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  733. return false
  734. } else {
  735. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  736. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  737. return false
  738. }
  739. }
  740. }
  741. // 单价
  742. if (this.create.createTemp.pricenew == 0) {
  743. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  744. return false
  745. } else {
  746. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  747. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  748. return false
  749. }
  750. }
  751. // 总价
  752. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  753. if (this.create.createTemp.sumprice == 0) {
  754. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  755. return false
  756. } else {
  757. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  758. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  759. return false
  760. }
  761. }
  762. }
  763. // 毛重
  764. if (this.create.createTemp.grossweight !== '') {
  765. if (this.create.createTemp.grossweight == 0) {
  766. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  767. return false
  768. } else {
  769. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  770. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  771. return false
  772. }
  773. }
  774. }
  775. // 皮重
  776. if (this.create.createTemp.tareweight !== '') {
  777. if (this.create.createTemp.tareweight == 0) {
  778. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  779. return false
  780. } else {
  781. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  782. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  783. return false
  784. }
  785. }
  786. }
  787. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  788. }).then(() => {
  789. this.isokDisable = true
  790. setTimeout(() => {
  791. this.isokDisable = false
  792. }, 1000)
  793. this.requestParam.common = { 'returnmap': '0' }
  794. this.requestParam.data = []
  795. this.requestParam.data[0] = { 'name': 'insertFeedlaid', 'type': 'e', 'parammaps': {
  796. 'pastureid': this.create.createTemp.pastureid,
  797. 'laiddate': this.create.createTemp.laiddate,
  798. 'feedid': this.create.createTemp.feedid,
  799. 'feedname': this.create.createTemp.feedname,
  800. 'providerid': this.create.createTemp.providerid,
  801. 'providername': this.create.createTemp.providername,
  802. 'contractcode': this.create.createTemp.contractcode,
  803. 'operateweight': this.create.createTemp.operateweight,
  804. 'grossweight': this.create.createTemp.grossweight,
  805. 'tareweight': this.create.createTemp.tareweight,
  806. 'sumprice': this.create.createTemp.sumprice,
  807. 'licence': this.create.createTemp.licence,
  808. 'pcpde': this.create.createTemp.pcpde,
  809. 'remark': this.create.createTemp.remark,
  810. 'createdate': this.create.createTemp.createdate,
  811. 'createemp': this.create.createTemp.createemp,
  812. 'startweight': this.create.createTemp.startweight,
  813. 'priceold': this.create.createTemp.priceold,
  814. 'pricenew': this.create.createTemp.pricenew,
  815. 'wagonnumber': this.create.createTemp.wagonnumber
  816. }}
  817. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  818. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  819. 'operateweight': this.create.createTemp.operateweight,
  820. 'pastureid': this.create.createTemp.pastureid,
  821. 'feedid': this.create.createTemp.feedid,
  822. 'fname': this.create.createTemp.fname,
  823. 'pcpde': this.create.createTemp.pcpde,
  824. 'stockweight': this.create.createTemp.startweight,
  825. 'price': this.create.createTemp.pricenew
  826. }}
  827. }
  828. console.log('点击了新增入库单保存', this.requestParam)
  829. ExecDataByConfig(this.requestParam).then(response => {
  830. if (response.msg === 'fail') {
  831. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  832. } else {
  833. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  834. this.create.dialogFormVisible = false
  835. this.getList()
  836. }
  837. })
  838. })
  839. }
  840. })
  841. },
  842. handleUpdate(row) {
  843. console.log('点击了编辑')
  844. this.$nextTick(() => {
  845. this.$refs.createTemp.resetFields()
  846. })
  847. this.create.dialogStatus = 'update'
  848. this.create.dialogFormVisible = true
  849. row.feedid = String(row.feedid)
  850. if (row.providerid == -1) {
  851. row.providerid = ''
  852. row.providername = ''
  853. }
  854. this.create.createTemp = Object.assign({}, row)
  855. },
  856. updateData() {
  857. this.$refs['createTemp'].validate(valid => {
  858. if (valid) {
  859. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  860. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  861. return false
  862. }
  863. if (this.create.createTemp.sumprice.length > 15) {
  864. this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
  865. }
  866. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  867. // 入库重量
  868. if (this.create.createTemp.operateweight !== '') {
  869. if (this.create.createTemp.operateweight == 0) {
  870. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  871. return false
  872. } else {
  873. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  874. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  875. return false
  876. }
  877. }
  878. }
  879. // 单价
  880. if (this.create.createTemp.pricenew == 0) {
  881. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  882. return false
  883. } else {
  884. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  885. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  886. return false
  887. }
  888. }
  889. // 总价
  890. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  891. if (this.create.createTemp.sumprice == 0) {
  892. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  893. return false
  894. } else {
  895. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  896. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  897. return false
  898. }
  899. }
  900. }
  901. // 毛重
  902. if (this.create.createTemp.grossweight !== '') {
  903. if (this.create.createTemp.grossweight == 0) {
  904. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  905. return false
  906. } else {
  907. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  908. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  909. return false
  910. }
  911. }
  912. }
  913. // 皮重
  914. if (this.create.createTemp.tareweight !== '') {
  915. if (this.create.createTemp.tareweight == 0) {
  916. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  917. return false
  918. } else {
  919. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  920. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  921. return false
  922. }
  923. }
  924. }
  925. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  926. }).then(() => {
  927. this.isokDisable = true
  928. setTimeout(() => {
  929. this.isokDisable = false
  930. }, 1000)
  931. this.requestParam.common = { 'returnmap': '0' }
  932. this.requestParam.data = []
  933. this.requestParam.data[0] = { 'name': 'updateFeedlaid', 'type': 'e', 'parammaps': {
  934. 'pastureid': this.create.createTemp.pastureid,
  935. 'id': this.create.createTemp.id,
  936. 'laiddate': this.create.createTemp.laiddate,
  937. 'feedid': this.create.createTemp.feedid,
  938. 'feedname': this.create.createTemp.feedname,
  939. 'providerid': this.create.createTemp.providerid,
  940. 'providername': this.create.createTemp.providername,
  941. 'contractcode': this.create.createTemp.contractcode,
  942. 'operateweight': this.create.createTemp.operateweight,
  943. 'grossweight': this.create.createTemp.grossweight,
  944. 'tareweight': this.create.createTemp.tareweight,
  945. 'sumprice': this.create.createTemp.sumprice,
  946. 'licence': this.create.createTemp.licence,
  947. 'pcpde': this.create.createTemp.pcpde,
  948. 'remark': this.create.createTemp.remark,
  949. 'createdate': this.create.createTemp.createdate,
  950. 'createemp': this.create.createTemp.createemp,
  951. 'startweight': this.create.createTemp.startweight,
  952. 'priceold': this.create.createTemp.priceold,
  953. 'pricenew': this.create.createTemp.pricenew,
  954. 'wagonnumber': this.create.createTemp.wagonnumber
  955. }}
  956. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  957. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  958. 'operateweight': this.create.createTemp.operateweight,
  959. 'pastureid': this.create.createTemp.pastureid,
  960. 'feedid': this.create.createTemp.feedid,
  961. 'fname': this.create.createTemp.fname,
  962. 'pcpde': this.create.createTemp.pcpde,
  963. 'stockweight': this.create.createTemp.startweight,
  964. 'price': this.create.createTemp.pricenew
  965. }}
  966. }
  967. console.log('点击了新增入库单保存', this.requestParam)
  968. ExecDataByConfig(this.requestParam).then(response => {
  969. if (response.msg === 'fail') {
  970. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  971. } else {
  972. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  973. this.create.dialogFormVisible = false
  974. this.getList()
  975. }
  976. })
  977. })
  978. }
  979. })
  980. },
  981. handleSee(row) {
  982. console.log('点击了查看')
  983. this.$nextTick(() => {
  984. this.$refs.createTemp.resetFields()
  985. })
  986. this.create.dialogStatus = 'see'
  987. this.create.dialogFormVisible = true
  988. if (row.providerid == -1) {
  989. row.providerid = ''
  990. row.providername = ''
  991. }
  992. this.create.createTemp = Object.assign({}, row)
  993. },
  994. handleInitial() {
  995. console.log('点击了初始化库存')
  996. this.initial.dialogStatus = 'initial'
  997. this.initial.dialogFormVisible = true
  998. this.getInitialList()
  999. },
  1000. getInitialList() {
  1001. this.initial.listLoading = true
  1002. GetDataByName(this.initial.getdataListParm).then(response => {
  1003. console.log('table数据', response.data.list)
  1004. if (response.data.list !== null) {
  1005. this.initial.list = response.data.list
  1006. this.initial.pageNum = response.data.pageNum
  1007. this.initial.pageSize = response.data.pageSize
  1008. this.initial.total = response.data.total
  1009. } else {
  1010. this.initial.list = []
  1011. }
  1012. setTimeout(() => {
  1013. this.initial.listLoading = false
  1014. }, 100)
  1015. })
  1016. },
  1017. handleInitialExport() {
  1018. console.log('点击了初始化库存导出')
  1019. const ExcelDatas = [
  1020. {
  1021. tHeader: ['饲料名称', '库存重量'],
  1022. filterVal: ['fname', 'stockweight'],
  1023. tableDatas: this.initial.list,
  1024. sheetName: '初始化库存'
  1025. }
  1026. ]
  1027. json2excel(ExcelDatas, '初始化库存', true, 'xlsx')
  1028. },
  1029. async handleInitialImport(eve) {
  1030. const file = eve.raw
  1031. if (!file) return
  1032. let reader = await upload(file)
  1033. const worker = xlsx.read(reader, { type: 'binary' })
  1034. // 将返回的数据转换为json对象的数据
  1035. reader = xlsx.utils.sheet_to_json(worker.Sheets[worker.SheetNames[0]])
  1036. console.log(reader)
  1037. const arr = []
  1038. reader.forEach(item => {
  1039. const obj = {}
  1040. for (const key in this.initial.character) {
  1041. if (!this.initial.character.hasOwnProperty(key)) break
  1042. let v = this.initial.character[key]
  1043. const text = v.text
  1044. const type = v.type
  1045. v = item[text] || ''
  1046. type === 'string' ? (v = String(v)) : null
  1047. type === 'number' ? (v = Number(v)) : null
  1048. obj[key] = v
  1049. }
  1050. arr.push(obj)
  1051. })
  1052. console.log('导入处理后数据', arr)
  1053. var sum = 0
  1054. for (let i = 0; i < this.initial.list.length; i++) {
  1055. for (let j = 0; j < arr.length; j++) {
  1056. if (this.initial.list[i].fname == arr[j].fname) {
  1057. this.initial.list[i].stockweight = arr[j].stockweight
  1058. sum++
  1059. arr.splice(j, 1)
  1060. }
  1061. }
  1062. }
  1063. console.log(arr)
  1064. for (let i = 0; i < arr.length; i++) {
  1065. this.$set(arr[i], 'msg', '饲料名称与系统不匹配')
  1066. }
  1067. console.log(sum)
  1068. this.$message({ title: '成功', message: '导入成功:' + sum + '条!', type: 'success', duration: 2000 })
  1069. this.$notify({ title: '失败', message: '导入失败:' + arr.length + '条!', type: 'danger', duration: 2000 })
  1070. if (arr.length > 0) {
  1071. const ExcelDatas1 = [
  1072. {
  1073. tHeader: ['饲料名称', '库存重量', '报错信息'],
  1074. filterVal: ['fname', 'stockweight', 'msg'],
  1075. tableDatas: arr,
  1076. sheetName: 'ExcelDatas1'
  1077. }
  1078. ]
  1079. json2excel(ExcelDatas1, '初始化库存报错信息', true, 'xlsx')
  1080. }
  1081. },
  1082. initialData() {
  1083. console.log('点击了初始化库存保存')
  1084. this.isokDisable = true
  1085. setTimeout(() => {
  1086. this.isokDisable = false
  1087. }, 1000)
  1088. var rulesStockweight = /^\d+(\.\d{1,2})?$/
  1089. for (let i = 0; i < this.initial.list.length; i++) {
  1090. if (!rulesStockweight.test(parseFloat(this.initial.list[i].stockweight))) {
  1091. this.$message({ type: 'warning', message: '库存重量不可小于0,且保留俩位小数', duration: 2000 })
  1092. return false
  1093. }
  1094. }
  1095. this.requestParam.common = { 'returnmap': '0' }
  1096. this.requestParam.data = []
  1097. this.requestParam.data[0] = { 'name': 'clearFS', 'type': 'e', 'parammaps': {
  1098. 'pastureid': Cookies.get('pastureid')
  1099. }}
  1100. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.initial.list }}
  1101. this.requestParam.data[1].children = []
  1102. this.requestParam.data[1].children[0] = { 'name': 'insertFeedstorage', 'type': 'e', 'parammaps': {
  1103. pastureid: '@insertSpotList.pastureid',
  1104. feedid: '@insertSpotList.feedid',
  1105. fname: '@insertSpotList.fname',
  1106. pcpde: '@insertSpotList.pcpde',
  1107. stockweight: '@insertSpotList.stockweight',
  1108. price: '@insertSpotList.price'
  1109. }}
  1110. ExecDataByConfig(this.requestParam).then(response => {
  1111. if (response.msg === 'fail') {
  1112. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1113. } else {
  1114. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  1115. this.create.dialogFormVisible = false
  1116. this.getList()
  1117. }
  1118. })
  1119. },
  1120. // 导出
  1121. handleExport(item) {
  1122. if (item == 1) {
  1123. console.log('点击了导出模板')
  1124. const requestParam = this.requestParam
  1125. const url = process.env.VUE_APP_BASE_API + 'file/导入导出模板/库存管理/入库导入模板.xlsx' // 请求下载文件的地址
  1126. console.log(url)
  1127. axios({
  1128. method: 'GET',
  1129. url: url,
  1130. data: requestParam,
  1131. headers: { token: getToken(), optname: 'insertcustomdoc' },
  1132. responseType: 'blob'
  1133. }).then(res => {
  1134. if (!res) return
  1135. this.percentage = 99
  1136. setTimeout(() => {
  1137. this.isPercentage = false
  1138. }, 2000)
  1139. const blob = new Blob([res.data], {
  1140. type: 'application/octet-stream;charset=utf-8'
  1141. })
  1142. const url = window.URL.createObjectURL(blob)
  1143. const aLink = document.createElement('a')
  1144. aLink.style.display = 'none'
  1145. aLink.href = url
  1146. const docname = '入库管理导入模板.xlsx'
  1147. aLink.setAttribute('download', docname) // 下载的文件
  1148. document.body.appendChild(aLink)
  1149. aLink.click()
  1150. document.body.removeChild(aLink)
  1151. window.URL.revokeObjectURL(url)
  1152. })
  1153. } else {
  1154. console.log('点击了导出数据')
  1155. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1156. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  1157. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  1158. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  1159. } else {
  1160. this.download.getdataListParm.parammaps.inputDatetime = ''
  1161. this.download.getdataListParm.parammaps.startTime = ''
  1162. this.download.getdataListParm.parammaps.stopTime = ''
  1163. }
  1164. GetDataByName(this.download.getdataListParm).then(response => {
  1165. if (response.data.list !== null) {
  1166. this.download.list = response.data.list
  1167. } else {
  1168. this.download.list = []
  1169. }
  1170. var excelDatas = [
  1171. {
  1172. tHeader: ['入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注'],
  1173. filterVal: ['laiddate', 'wagonnumber', 'feedname', 'providername', 'contractcode', 'operateweight', 'pricenew', 'sumprice', 'grossweight', 'tareweight', 'licence', 'pcpde', 'createemp', 'createdate', 'remark'],
  1174. tableDatas: this.download.list,
  1175. sheetName: 'Sheet1'
  1176. }
  1177. ]
  1178. json2excel(excelDatas, '入库管理', true, 'xlsx')
  1179. })
  1180. }
  1181. },
  1182. beforeImport(file) {
  1183. const isLt2M = file.size / 1024 / 1024 < 2
  1184. if (!isLt2M) {
  1185. this.$message.error('上传文件大小不能超过 2MB!')
  1186. }
  1187. return isLt2M
  1188. },
  1189. handleImportSuccess(res, file) {
  1190. this.getList()
  1191. if (res.msg === 'ok') {
  1192. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1193. if (res.data.err_count > 0) {
  1194. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1195. import('@/vendor/Export2Excel').then(excel => {
  1196. const list1 = res.data.result
  1197. const tHeader = [
  1198. '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', '错误信息'
  1199. ]
  1200. const filterVal = [
  1201. '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', 'error_msg'
  1202. ]
  1203. const data1 = this.formatJson(filterVal, list1)
  1204. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '入库管理导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1205. })
  1206. }
  1207. } else {
  1208. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1209. }
  1210. },
  1211. formatJson(filterVal, jsonData) {
  1212. return jsonData.map(v =>
  1213. filterVal.map(j => {
  1214. if (j === 'timestamp') {
  1215. return parseTime(v[j])
  1216. } else {
  1217. return v[j]
  1218. }
  1219. })
  1220. )
  1221. }
  1222. }
  1223. }
  1224. </script>
  1225. <style lang="scss" scoped>
  1226. .search{margin-top:10px;}
  1227. .table{margin-top:10px;}
  1228. </style>