efc82fb09343f86b72cd73374506c2c816aebf55.svn-base 59 KB

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