687de08e66c79890c9af9371da5ff2ce1e339e90.svn-base 58 KB

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