ec2752c13cb186f24f978671b648fe6426a9d6b2.svn-base 60 KB

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