537e61b09a7dd4ba6f255fb2ae8802e615144c9a.svn-base 59 KB

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