a212f6248e6d51ab57ba0c01366960d7740b25dc.svn-base 56 KB

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