index改.vue 60 KB

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