c844a488b227cae0629311c3686399705f736f64.svn-base 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  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 { 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: 50 + 'px', height: 45 + '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: '颛孙洋洋-入库',
  436. importParams: '入库日期,送货单编号,饲料名称,供应商,合同编号,入库重量(kg),单价(元),总价(元),毛重(kg),皮重(kg),许可证号,批号,创建人,创建日期,备注',
  437. sheetname: 'SheetJS'
  438. }
  439. },
  440. // 设置上传地址
  441. uploadExcelUrl() {
  442. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  443. }
  444. },
  445. created() {
  446. this.getButtons()
  447. this.getDownList()
  448. this.getList()
  449. },
  450. methods: {
  451. getButtons() {
  452. const Edit = 'Warehousing'
  453. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  454. this.isRoleEdit = isRoleEdit
  455. },
  456. getDownList() {
  457. GetDataByNames(this.requestParams).then(response => {
  458. this.feedNameList = response.data.getFeedListEnable.list
  459. this.supplierList = response.data.getProviderListEnable.list
  460. })
  461. },
  462. handleBefore() {
  463. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  464. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  465. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  466. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  467. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  468. this.$forceUpdate()
  469. }
  470. },
  471. handleNext() {
  472. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  473. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  474. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  475. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  476. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  477. this.$forceUpdate()
  478. }
  479. },
  480. getList() {
  481. this.table.listLoading = true
  482. GetDataByName(this.table.getdataListParm).then(response => {
  483. console.log('table数据', response.data.list)
  484. if (response.data.list !== null) {
  485. this.table.list = response.data.list
  486. this.table.pageNum = response.data.pageNum
  487. this.table.pageSize = response.data.pageSize
  488. this.table.total = response.data.total
  489. } else {
  490. this.table.list = []
  491. }
  492. setTimeout(() => {
  493. this.table.listLoading = false
  494. }, 100)
  495. })
  496. },
  497. handleSearch() {
  498. // console.log('点击了查询')
  499. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  500. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  501. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  502. } else {
  503. this.table.getdataListParm.parammaps.inputDatetime = ''
  504. this.table.getdataListParm.parammaps.startTime = ''
  505. this.table.getdataListParm.parammaps.stopTime = ''
  506. }
  507. this.table.getdataListParm.offset = 1
  508. this.getList()
  509. },
  510. handleRefresh() {
  511. console.log('点击了重置')
  512. this.table.getdataListParm.parammaps.inputDatetime = ''
  513. this.table.getdataListParm.parammaps.startTime = ''
  514. this.table.getdataListParm.parammaps.stopTime = ''
  515. this.table.getdataListParm.parammaps.feedid = ''
  516. this.table.getdataListParm.parammaps.islaid = ''
  517. this.table.getdataListParm.parammaps.providerid = ''
  518. this.table.getdataListParm.offset = 1
  519. this.getList()
  520. },
  521. resetCreateTemp() {
  522. this.create.createTemp = {
  523. 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': ''
  524. }
  525. this.contractNoList = []
  526. },
  527. // 供应商
  528. changeSupplier(item) {
  529. console.log(item)
  530. if (item !== '') {
  531. this.create.createTemp.providername = this.supplierList.find(obj => obj.id == item).providerName
  532. } else {
  533. this.create.createTemp.providername = ''
  534. this.create.createTemp.contractcode = ''
  535. this.create.createTemp.pricenew = ''
  536. this.create.createTemp.sumprice = ''
  537. this.contractNoList = []
  538. }
  539. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  540. this.getContractNoList()
  541. }
  542. },
  543. // 合同编号
  544. changeContractNo(item) {
  545. if (item !== '') {
  546. this.create.createTemp.pricenew = this.contractNoList.find(obj => obj.contractcode == item).price
  547. } else {
  548. this.create.createTemp.pricenew = ''
  549. }
  550. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  551. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  552. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  553. }
  554. },
  555. getContractNoList() {
  556. this.create.getdataListParm.parammaps.feedid = this.create.createTemp.feedid
  557. this.create.getdataListParm.parammaps.providerid = this.create.createTemp.providerid
  558. GetDataByName(this.create.getdataListParm).then(response => {
  559. console.log('table数据', response.data.list)
  560. if (response.data.list !== null) {
  561. this.contractNoList = response.data.list
  562. this.create.createTemp.contractcode = ''
  563. this.create.createTemp.pricenew = ''
  564. this.create.createTemp.sumprice = ''
  565. } else {
  566. this.contractNoList = []
  567. this.create.createTemp.contractcode = ''
  568. this.create.createTemp.pricenew = ''
  569. this.create.createTemp.sumprice = ''
  570. }
  571. })
  572. },
  573. feedNameSearch(queryString, cb) {
  574. this.create.getfeedNameParm.parammaps['fname'] = queryString
  575. GetDataByName(this.create.getfeedNameParm).then(response => {
  576. console.log('模糊查询搜索data', response.data.list)
  577. if (response.data.list == null) {
  578. cb([])
  579. } else {
  580. cb(response.data.list)
  581. }
  582. })
  583. },
  584. handleSelectFeedName(item) {
  585. console.log('模糊查询选中值', item)
  586. this.create.createTemp.feedname = item.fname
  587. this.create.createTemp.feedid = item.id
  588. this.create.createTemp.startweight = item.stockweight
  589. this.create.createTemp.priceold = item.price
  590. this.create.createTemp.providerid = ''
  591. this.create.createTemp.providername = ''
  592. this.create.createTemp.contractcode = ''
  593. this.create.createTemp.pricenew = ''
  594. this.create.createTemp.sumprice = ''
  595. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  596. this.getContractNoList()
  597. }
  598. },
  599. blurFeedName() {
  600. this.create.createTemp.feedname = ''
  601. this.create.createTemp.feedid = ''
  602. this.create.createTemp.startweight = ''
  603. this.create.createTemp.priceold = ''
  604. this.create.createTemp.providerid = ''
  605. this.create.createTemp.providername = ''
  606. this.create.createTemp.contractcode = ''
  607. this.create.createTemp.pricenew = ''
  608. this.create.createTemp.sumprice = ''
  609. },
  610. // 入库重量
  611. blurOperateweight() {
  612. // 毛重grossweight皮重tareweight入库重量operateweight
  613. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  614. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight), 2)
  615. }
  616. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  617. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  618. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  619. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  620. }
  621. }
  622. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  623. if (this.create.createTemp.operateweight == '') {
  624. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  625. }
  626. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  627. this.create.createTemp.tareweight = formatNum(this.create.createTemp.grossweight, 2)
  628. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  629. }
  630. }
  631. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  632. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  633. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  634. } else {
  635. this.create.createTemp.sumprice = ''
  636. }
  637. },
  638. // 毛重
  639. blurGrossweight() {
  640. // 毛重grossweight皮重tareweight入库重量operateweight
  641. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  642. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight), 2)
  643. }
  644. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  645. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  646. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  647. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  648. }
  649. }
  650. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  651. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  652. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  653. } else {
  654. this.create.createTemp.sumprice = ''
  655. }
  656. },
  657. // 皮重
  658. blurTareweight() {
  659. // 毛重grossweight皮重tareweight入库重量operateweight
  660. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.tareweight !== '') {
  661. this.create.createTemp.grossweight = formatNum(parseFloat(this.create.createTemp.tareweight) + parseFloat(this.create.createTemp.operateweight), 2)
  662. }
  663. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  664. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  665. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  666. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  667. }
  668. }
  669. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  670. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  671. this.create.createTemp.tareweight = formatNum(this.create.createTemp.grossweight, 2)
  672. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  673. } else {
  674. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  675. }
  676. }
  677. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  678. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  679. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  680. } else {
  681. this.create.createTemp.sumprice = ''
  682. }
  683. },
  684. // 单价
  685. blurPricenew() {
  686. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  687. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  688. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  689. } else {
  690. this.create.createTemp.sumprice = ''
  691. }
  692. },
  693. // 总价
  694. blurSumprice() {
  695. if (this.create.createTemp.sumprice !== '' && this.create.createTemp.pricenew !== '') {
  696. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.sumprice) / parseFloat(this.create.createTemp.pricenew), 2)
  697. } else {
  698. this.create.createTemp.operateweight = ''
  699. }
  700. },
  701. handleCreate() {
  702. console.log('点击了新增入库单')
  703. this.create.dialogStatus = 'create'
  704. this.create.dialogFormVisible = true
  705. this.$nextTick(() => {
  706. this.resetCreateTemp()
  707. this.$refs.createTemp.resetFields()
  708. })
  709. },
  710. createData() {
  711. this.$refs['createTemp'].validate(valid => {
  712. if (valid) {
  713. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  714. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  715. return false
  716. }
  717. if (this.create.createTemp.sumprice.length > 15) {
  718. this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
  719. }
  720. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  721. // 入库重量
  722. if (this.create.createTemp.operateweight !== '') {
  723. if (this.create.createTemp.operateweight == 0) {
  724. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  725. return false
  726. } else {
  727. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  728. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  729. return false
  730. }
  731. }
  732. }
  733. // 单价
  734. if (this.create.createTemp.pricenew == 0) {
  735. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  736. return false
  737. } else {
  738. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  739. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  740. return false
  741. }
  742. }
  743. // 总价
  744. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  745. if (this.create.createTemp.sumprice == 0) {
  746. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  747. return false
  748. } else {
  749. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  750. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  751. return false
  752. }
  753. }
  754. }
  755. // 毛重
  756. if (this.create.createTemp.grossweight !== '') {
  757. if (this.create.createTemp.grossweight == 0) {
  758. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  759. return false
  760. } else {
  761. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  762. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  763. return false
  764. }
  765. }
  766. }
  767. // 皮重
  768. if (this.create.createTemp.tareweight !== '') {
  769. if (this.create.createTemp.tareweight == 0) {
  770. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  771. return false
  772. } else {
  773. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  774. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  775. return false
  776. }
  777. }
  778. }
  779. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  780. }).then(() => {
  781. this.isokDisable = true
  782. setTimeout(() => {
  783. this.isokDisable = false
  784. }, 1000)
  785. this.requestParam.common = { 'returnmap': '0' }
  786. this.requestParam.data = []
  787. this.requestParam.data[0] = { 'name': 'insertFeedlaid', 'type': 'e', 'parammaps': {
  788. 'pastureid': this.create.createTemp.pastureid,
  789. 'laiddate': this.create.createTemp.laiddate,
  790. 'feedid': this.create.createTemp.feedid,
  791. 'feedname': this.create.createTemp.feedname,
  792. 'providerid': this.create.createTemp.providerid,
  793. 'providername': this.create.createTemp.providername,
  794. 'contractcode': this.create.createTemp.contractcode,
  795. 'operateweight': this.create.createTemp.operateweight,
  796. 'grossweight': this.create.createTemp.grossweight,
  797. 'tareweight': this.create.createTemp.tareweight,
  798. 'sumprice': this.create.createTemp.sumprice,
  799. 'licence': this.create.createTemp.licence,
  800. 'pcpde': this.create.createTemp.pcpde,
  801. 'remark': this.create.createTemp.remark,
  802. 'createdate': this.create.createTemp.createdate,
  803. 'createemp': this.create.createTemp.createemp,
  804. 'startweight': this.create.createTemp.startweight,
  805. 'priceold': this.create.createTemp.priceold,
  806. 'pricenew': this.create.createTemp.pricenew,
  807. 'wagonnumber': this.create.createTemp.wagonnumber
  808. }}
  809. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  810. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  811. 'operateweight': this.create.createTemp.operateweight,
  812. 'pastureid': this.create.createTemp.pastureid,
  813. 'feedid': this.create.createTemp.feedid,
  814. 'fname': this.create.createTemp.fname,
  815. 'pcpde': this.create.createTemp.pcpde,
  816. 'stockweight': this.create.createTemp.startweight,
  817. 'price': this.create.createTemp.pricenew
  818. }}
  819. }
  820. console.log('点击了新增入库单保存', this.requestParam)
  821. ExecDataByConfig(this.requestParam).then(response => {
  822. if (response.msg === 'fail') {
  823. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  824. } else {
  825. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  826. this.create.dialogFormVisible = false
  827. this.getList()
  828. }
  829. })
  830. })
  831. }
  832. })
  833. },
  834. handleUpdate(row) {
  835. console.log('点击了编辑')
  836. this.$nextTick(() => {
  837. this.$refs.createTemp.resetFields()
  838. })
  839. this.create.dialogStatus = 'update'
  840. this.create.dialogFormVisible = true
  841. row.feedid = String(row.feedid)
  842. if (row.providerid == -1) {
  843. row.providerid = ''
  844. row.providername = ''
  845. }
  846. this.create.createTemp = Object.assign({}, row)
  847. },
  848. updateData() {
  849. this.$refs['createTemp'].validate(valid => {
  850. if (valid) {
  851. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  852. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  853. return false
  854. }
  855. if (this.create.createTemp.sumprice.length > 15) {
  856. this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
  857. }
  858. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  859. // 入库重量
  860. if (this.create.createTemp.operateweight !== '') {
  861. if (this.create.createTemp.operateweight == 0) {
  862. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  863. return false
  864. } else {
  865. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  866. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  867. return false
  868. }
  869. }
  870. }
  871. // 单价
  872. if (this.create.createTemp.pricenew == 0) {
  873. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  874. return false
  875. } else {
  876. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  877. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  878. return false
  879. }
  880. }
  881. // 总价
  882. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  883. if (this.create.createTemp.sumprice == 0) {
  884. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  885. return false
  886. } else {
  887. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  888. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  889. return false
  890. }
  891. }
  892. }
  893. // 毛重
  894. if (this.create.createTemp.grossweight !== '') {
  895. if (this.create.createTemp.grossweight == 0) {
  896. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  897. return false
  898. } else {
  899. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  900. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  901. return false
  902. }
  903. }
  904. }
  905. // 皮重
  906. if (this.create.createTemp.tareweight !== '') {
  907. if (this.create.createTemp.tareweight == 0) {
  908. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  909. return false
  910. } else {
  911. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  912. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  913. return false
  914. }
  915. }
  916. }
  917. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  918. }).then(() => {
  919. this.isokDisable = true
  920. setTimeout(() => {
  921. this.isokDisable = false
  922. }, 1000)
  923. this.requestParam.common = { 'returnmap': '0' }
  924. this.requestParam.data = []
  925. this.requestParam.data[0] = { 'name': 'updateFeedlaid', 'type': 'e', 'parammaps': {
  926. 'pastureid': this.create.createTemp.pastureid,
  927. 'id': this.create.createTemp.id,
  928. 'laiddate': this.create.createTemp.laiddate,
  929. 'feedid': this.create.createTemp.feedid,
  930. 'feedname': this.create.createTemp.feedname,
  931. 'providerid': this.create.createTemp.providerid,
  932. 'providername': this.create.createTemp.providername,
  933. 'contractcode': this.create.createTemp.contractcode,
  934. 'operateweight': this.create.createTemp.operateweight,
  935. 'grossweight': this.create.createTemp.grossweight,
  936. 'tareweight': this.create.createTemp.tareweight,
  937. 'sumprice': this.create.createTemp.sumprice,
  938. 'licence': this.create.createTemp.licence,
  939. 'pcpde': this.create.createTemp.pcpde,
  940. 'remark': this.create.createTemp.remark,
  941. 'createdate': this.create.createTemp.createdate,
  942. 'createemp': this.create.createTemp.createemp,
  943. 'startweight': this.create.createTemp.startweight,
  944. 'priceold': this.create.createTemp.priceold,
  945. 'pricenew': this.create.createTemp.pricenew,
  946. 'wagonnumber': this.create.createTemp.wagonnumber
  947. }}
  948. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  949. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  950. 'operateweight': this.create.createTemp.operateweight,
  951. 'pastureid': this.create.createTemp.pastureid,
  952. 'feedid': this.create.createTemp.feedid,
  953. 'fname': this.create.createTemp.fname,
  954. 'pcpde': this.create.createTemp.pcpde,
  955. 'stockweight': this.create.createTemp.startweight,
  956. 'price': this.create.createTemp.pricenew
  957. }}
  958. }
  959. console.log('点击了新增入库单保存', this.requestParam)
  960. ExecDataByConfig(this.requestParam).then(response => {
  961. if (response.msg === 'fail') {
  962. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  963. } else {
  964. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  965. this.create.dialogFormVisible = false
  966. this.getList()
  967. }
  968. })
  969. })
  970. }
  971. })
  972. },
  973. handleSee(row) {
  974. console.log('点击了查看')
  975. this.$nextTick(() => {
  976. this.$refs.createTemp.resetFields()
  977. })
  978. this.create.dialogStatus = 'see'
  979. this.create.dialogFormVisible = true
  980. if (row.providerid == -1) {
  981. row.providerid = ''
  982. row.providername = ''
  983. }
  984. this.create.createTemp = Object.assign({}, row)
  985. },
  986. handleInitial() {
  987. console.log('点击了初始化库存')
  988. this.initial.dialogStatus = 'initial'
  989. this.initial.dialogFormVisible = true
  990. this.getInitialList()
  991. },
  992. getInitialList() {
  993. this.initial.listLoading = true
  994. GetDataByName(this.initial.getdataListParm).then(response => {
  995. console.log('table数据', response.data.list)
  996. if (response.data.list !== null) {
  997. this.initial.list = response.data.list
  998. this.initial.pageNum = response.data.pageNum
  999. this.initial.pageSize = response.data.pageSize
  1000. this.initial.total = response.data.total
  1001. } else {
  1002. this.initial.list = []
  1003. }
  1004. setTimeout(() => {
  1005. this.initial.listLoading = false
  1006. }, 100)
  1007. })
  1008. },
  1009. handleInitialExport() {
  1010. console.log('点击了初始化库存导出')
  1011. const ExcelDatas = [
  1012. {
  1013. tHeader: ['饲料名称', '库存重量'],
  1014. filterVal: ['fname', 'stockweight'],
  1015. tableDatas: this.initial.list,
  1016. sheetName: '初始化库存'
  1017. }
  1018. ]
  1019. json2excel(ExcelDatas, '初始化库存', true, 'xlsx')
  1020. },
  1021. async handleInitialImport(eve) {
  1022. const file = eve.raw
  1023. if (!file) return
  1024. let reader = await upload(file)
  1025. const worker = xlsx.read(reader, { type: 'binary' })
  1026. // 将返回的数据转换为json对象的数据
  1027. reader = xlsx.utils.sheet_to_json(worker.Sheets[worker.SheetNames[0]])
  1028. console.log(reader)
  1029. const arr = []
  1030. reader.forEach(item => {
  1031. const obj = {}
  1032. for (const key in this.initial.character) {
  1033. if (!this.initial.character.hasOwnProperty(key)) break
  1034. let v = this.initial.character[key]
  1035. const text = v.text
  1036. const type = v.type
  1037. v = item[text] || ''
  1038. type === 'string' ? (v = String(v)) : null
  1039. type === 'number' ? (v = Number(v)) : null
  1040. obj[key] = v
  1041. }
  1042. arr.push(obj)
  1043. })
  1044. console.log('导入处理后数据', arr)
  1045. var sum = 0
  1046. for (let i = 0; i < this.initial.list.length; i++) {
  1047. for (let j = 0; j < arr.length; j++) {
  1048. if (this.initial.list[i].fname == arr[j].fname) {
  1049. this.initial.list[i].stockweight = arr[j].stockweight
  1050. sum++
  1051. arr.splice(j, 1)
  1052. }
  1053. }
  1054. }
  1055. console.log(arr)
  1056. for (let i = 0; i < arr.length; i++) {
  1057. this.$set(arr[i], 'msg', '饲料名称与系统不匹配')
  1058. }
  1059. console.log(sum)
  1060. this.$message({ title: '成功', message: '导入成功:' + sum + '条!', type: 'success', duration: 2000 })
  1061. this.$notify({ title: '失败', message: '导入失败:' + arr.length + '条!', type: 'danger', duration: 2000 })
  1062. if (arr.length > 0) {
  1063. const ExcelDatas1 = [
  1064. {
  1065. tHeader: ['饲料名称', '库存重量', '报错信息'],
  1066. filterVal: ['fname', 'stockweight', 'msg'],
  1067. tableDatas: arr,
  1068. sheetName: 'ExcelDatas1'
  1069. }
  1070. ]
  1071. json2excel(ExcelDatas1, '初始化库存报错信息', true, 'xlsx')
  1072. }
  1073. },
  1074. initialData() {
  1075. console.log('点击了初始化库存保存')
  1076. this.isokDisable = true
  1077. setTimeout(() => {
  1078. this.isokDisable = false
  1079. }, 1000)
  1080. var rulesStockweight = /^\d+(\.\d{1,2})?$/
  1081. for (let i = 0; i < this.initial.list.length; i++) {
  1082. if (!rulesStockweight.test(parseFloat(this.initial.list[i].stockweight))) {
  1083. this.$message({ type: 'warning', message: '库存重量不可小于0,且保留俩位小数', duration: 2000 })
  1084. return false
  1085. }
  1086. }
  1087. this.requestParam.common = { 'returnmap': '0' }
  1088. this.requestParam.data = []
  1089. this.requestParam.data[0] = { 'name': 'clearFS', 'type': 'e', 'parammaps': {
  1090. 'pastureid': Cookies.get('pastureid')
  1091. }}
  1092. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.initial.list }}
  1093. this.requestParam.data[1].children = []
  1094. this.requestParam.data[1].children[0] = { 'name': 'insertFeedstorage', 'type': 'e', 'parammaps': {
  1095. pastureid: '@insertSpotList.pastureid',
  1096. feedid: '@insertSpotList.feedid',
  1097. fname: '@insertSpotList.fname',
  1098. pcpde: '@insertSpotList.pcpde',
  1099. stockweight: '@insertSpotList.stockweight',
  1100. price: '@insertSpotList.price'
  1101. }}
  1102. ExecDataByConfig(this.requestParam).then(response => {
  1103. if (response.msg === 'fail') {
  1104. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1105. } else {
  1106. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  1107. this.create.dialogFormVisible = false
  1108. this.getList()
  1109. }
  1110. })
  1111. },
  1112. // 导出
  1113. handleExport(item) {
  1114. if (item == 1) {
  1115. console.log('点击了导出模板')
  1116. } else {
  1117. console.log('点击了导出数据')
  1118. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1119. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  1120. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  1121. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  1122. } else {
  1123. this.download.getdataListParm.parammaps.inputDatetime = ''
  1124. this.download.getdataListParm.parammaps.startTime = ''
  1125. this.download.getdataListParm.parammaps.stopTime = ''
  1126. }
  1127. GetDataByName(this.download.getdataListParm).then(response => {
  1128. if (response.data.list !== null) {
  1129. this.download.list = response.data.list
  1130. } else {
  1131. this.download.list = []
  1132. }
  1133. var excelDatas = [
  1134. {
  1135. tHeader: ['入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注'],
  1136. filterVal: ['laiddate', 'wagonnumber', 'feedname', 'providername', 'contractcode', 'operateweight', 'pricenew', 'sumprice', 'grossweight', 'tareweight', 'licence', 'pcpde', 'createemp', 'createdate', 'remark'],
  1137. tableDatas: this.download.list,
  1138. sheetName: 'Sheet1'
  1139. }
  1140. ]
  1141. json2excel(excelDatas, '入库管理', true, 'xlsx')
  1142. })
  1143. }
  1144. },
  1145. beforeImport(file) {
  1146. const isLt2M = file.size / 1024 / 1024 < 2
  1147. if (!isLt2M) {
  1148. this.$message.error('上传文件大小不能超过 2MB!')
  1149. }
  1150. return isLt2M
  1151. },
  1152. handleImportSuccess(res, file) {
  1153. this.getList()
  1154. if (res.msg === 'ok') {
  1155. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1156. if (res.data.err_count > 0) {
  1157. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1158. import('@/vendor/Export2Excel').then(excel => {
  1159. const list1 = res.data.result
  1160. const tHeader = [
  1161. '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', '错误信息'
  1162. ]
  1163. const filterVal = [
  1164. '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', 'error_msg'
  1165. ]
  1166. const data1 = this.formatJson(filterVal, list1)
  1167. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '入库管理导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1168. })
  1169. }
  1170. } else {
  1171. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1172. }
  1173. },
  1174. formatJson(filterVal, jsonData) {
  1175. return jsonData.map(v =>
  1176. filterVal.map(j => {
  1177. if (j === 'timestamp') {
  1178. return parseTime(v[j])
  1179. } else {
  1180. return v[j]
  1181. }
  1182. })
  1183. )
  1184. }
  1185. }
  1186. }
  1187. </script>
  1188. <style lang="scss" scoped>
  1189. .search{margin-top:10px;}
  1190. .table{margin-top:10px;}
  1191. </style>