index.vue 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  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.id" />
  15. </el-select>
  16. <el-button class="successBorder" @click="form_search">查询</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. :max-height="myHeight"
  46. >
  47. <el-table-column label="序号" align="center" type="index" width="50px">
  48. <template slot-scope="scope">
  49. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="入库日期" min-width="90px" align="center">
  53. <template slot-scope="scope">
  54. <span>{{ scope.row.laiddate }}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="饲料名称" min-width="90px" align="center">
  58. <template slot-scope="scope">
  59. <span>{{ scope.row.feedname }}</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="供应商" min-width="90px" align="center">
  63. <template slot-scope="scope">
  64. <span>{{ scope.row.providername }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="入库重量(kg)" min-width="90px" align="center">
  68. <template slot-scope="scope">
  69. <span>{{ scope.row.operateweight }}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="总价(元)" min-width="90px" align="center">
  73. <template slot-scope="scope">
  74. <span>{{ scope.row.sumprice }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="批号" min-width="90px" align="center">
  78. <template slot-scope="scope">
  79. <span>{{ scope.row.pcpde }}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="备注" min-width="90px" align="center">
  83. <template slot-scope="scope">
  84. <span>{{ scope.row.remark }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="入库状态" min-width="90px" align="center">
  88. <template slot-scope="scope">
  89. <span>{{ scope.row.islaid }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="创建人" min-width="90px" align="center">
  93. <template slot-scope="scope">
  94. <span>{{ scope.row.createemp }}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="创建日期" min-width="90px" align="center">
  98. <template slot-scope="scope">
  99. <span>{{ scope.row.createdate }}</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  103. <template slot-scope="{row}">
  104. <el-button class="miniSuccess" icon="el-icon-search" @click="form_see(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" v-if='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: '已入库' }], // 是否入库
  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. operateweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  378. feedname: [{ type: 'string', required: true, message: '必填', trigger: 'change' }],
  379. pricenew: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  380. },
  381. getdataListParm: {
  382. name: 'getBigContractListEnable',
  383. offset: 0,
  384. pagecount: '',
  385. parammaps: { pastureid: Cookies.get('pastureid') }
  386. },
  387. getfeedNameParm: {
  388. name: 'getFeedListEnableV2',
  389. offset: 0,
  390. pagecount: '',
  391. parammaps: { pastureid: Cookies.get('pastureid') }
  392. }
  393. },
  394. initial: {
  395. dialogFormVisible: false,
  396. dialogStatus: '',
  397. rules: {},
  398. getdataListParm: {
  399. name: 'getinitFeed',
  400. page: 1,
  401. offset: 1,
  402. pagecount: 6,
  403. returntype: 'Map',
  404. parammaps: {
  405. pastureid: Cookies.get('pastureid')
  406. }
  407. },
  408. tableKey: 0,
  409. list: [],
  410. total: 0,
  411. listLoading: true,
  412. character: {
  413. fname: {
  414. text: '饲料名称',
  415. type: String
  416. },
  417. stockweight: {
  418. text: '库存重量',
  419. type: String
  420. }
  421. }
  422. },
  423. textMap: {
  424. create: '新增入库单',
  425. update: '编辑入库单',
  426. see: '查看入库单',
  427. initial: '初始化库存'
  428. },
  429. requestParam: {},
  430. download: {
  431. getdataListParm: {
  432. name: 'getFeedlaidList',
  433. page: 1,
  434. offset: 1,
  435. pagecount: 0,
  436. returntype: 'Map',
  437. parammaps: {
  438. pastureid: Cookies.get('pastureid'),
  439. inputDatetime: '',
  440. startTime: '',
  441. stopTime: '',
  442. feedid: '',
  443. islaid: '',
  444. providerid: ''
  445. }
  446. },
  447. list: []
  448. },
  449. isokDisable: false,
  450. isRoleEdit: [],
  451. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  452. cellStyle: { padding: 0 + 'px' },
  453. myHeight:document.documentElement.clientHeight - 85- 150 - 45
  454. }
  455. },
  456. computed: {
  457. // 设置请求头
  458. headers() {
  459. return {
  460. token: getToken()
  461. }
  462. },
  463. uploadData() {
  464. return {
  465. name: 'checkFeed,checkProviderRK,checkcontractcode,checkcontractcodePrice,insertFeedlaidUpload,insertFeedstorageLaidUpload',
  466. importParams: '入库日期,送货单编号,饲料名称,供应商,合同编号,入库重量(kg),单价(元),总价(元),毛重(kg),皮重(kg),许可证号,批号,创建人,备注',
  467. sheetname: 'Sheet1',
  468. // 登录牧场
  469. pastureid: Cookies.get('pastureid'),
  470. // 日期参数
  471. dateParams: '入库日期',
  472. // 必填参数
  473. requiredParams: '入库日期,饲料名称,入库重量(kg),单价(元)',
  474. // 为数值的参数
  475. numParams: '入库重量(kg),单价(元),总价(元),毛重(kg),皮重(kg)'
  476. }
  477. },
  478. // 设置上传地址
  479. uploadExcelUrl() {
  480. return Cookies.get('url') + 'authdata/ImportExcel'
  481. }
  482. },
  483. created() {
  484. this.getButtons()
  485. this.getDownList()
  486. this.getList()
  487. },
  488. methods: {
  489. getButtons() {
  490. const Edit = 'Warehousing'
  491. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  492. this.isRoleEdit = isRoleEdit
  493. },
  494. getDownList() {
  495. GetDataByNames(this.requestParams).then(response => {
  496. this.feedNameList = response.data.getFeedListEnable.list
  497. this.supplierList = response.data.getProviderListEnable.list
  498. })
  499. },
  500. handleBefore() {
  501. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  502. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  503. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  504. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  505. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  506. this.$forceUpdate()
  507. }
  508. },
  509. handleNext() {
  510. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  511. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  512. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  513. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  514. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  515. this.$forceUpdate()
  516. }
  517. },
  518. getList() {
  519. this.table.listLoading = true
  520. GetDataByName(this.table.getdataListParm).then(response => {
  521. console.log('table数据', response.data.list)
  522. if (response.data.list !== null) {
  523. this.table.list = response.data.list
  524. this.table.pageNum = response.data.pageNum
  525. this.table.pageSize = response.data.pageSize
  526. } else {
  527. this.table.list = []
  528. }
  529. this.table.total = response.data.total
  530. setTimeout(() => {
  531. this.table.listLoading = false
  532. }, 100)
  533. })
  534. },
  535. form_search() {
  536. // console.log('点击了查询')
  537. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  538. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  539. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  540. } else {
  541. this.table.getdataListParm.parammaps.inputDatetime = ''
  542. this.table.getdataListParm.parammaps.startTime = ''
  543. this.table.getdataListParm.parammaps.stopTime = ''
  544. }
  545. this.table.getdataListParm.offset = 1
  546. this.getList()
  547. },
  548. handleRefresh() {
  549. console.log('点击了重置')
  550. this.table.getdataListParm.parammaps.inputDatetime = ''
  551. this.table.getdataListParm.parammaps.startTime = ''
  552. this.table.getdataListParm.parammaps.stopTime = ''
  553. this.table.getdataListParm.parammaps.feedid = ''
  554. this.table.getdataListParm.parammaps.islaid = ''
  555. this.table.getdataListParm.parammaps.providerid = ''
  556. this.table.getdataListParm.offset = 1
  557. this.getList()
  558. },
  559. resetCreateTemp() {
  560. this.create.createTemp = {
  561. 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': ''
  562. }
  563. this.contractNoList = []
  564. },
  565. // 供应商
  566. changeSupplier(item) {
  567. console.log(item)
  568. if (item !== '') {
  569. this.create.createTemp.providername = this.supplierList.find(obj => obj.id == item).providerName
  570. } else {
  571. this.create.createTemp.providername = ''
  572. this.create.createTemp.contractcode = ''
  573. this.create.createTemp.pricenew = ''
  574. this.create.createTemp.sumprice = ''
  575. this.contractNoList = []
  576. }
  577. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  578. this.getContractNoList()
  579. }
  580. },
  581. // 合同编号
  582. changeContractNo(item) {
  583. if (item !== '') {
  584. this.create.createTemp.pricenew = this.contractNoList.find(obj => obj.contractcode == item).price
  585. } else {
  586. this.create.createTemp.pricenew = ''
  587. }
  588. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  589. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  590. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  591. }
  592. },
  593. getContractNoList() {
  594. this.create.getdataListParm.parammaps.feedid = this.create.createTemp.feedid
  595. this.create.getdataListParm.parammaps.providerid = this.create.createTemp.providerid
  596. GetDataByName(this.create.getdataListParm).then(response => {
  597. console.log('table数据', response.data.list)
  598. if (response.data.list !== null) {
  599. this.contractNoList = response.data.list
  600. this.create.createTemp.contractcode = ''
  601. this.create.createTemp.pricenew = ''
  602. this.create.createTemp.sumprice = ''
  603. } else {
  604. this.contractNoList = []
  605. this.create.createTemp.contractcode = ''
  606. this.create.createTemp.pricenew = ''
  607. this.create.createTemp.sumprice = ''
  608. }
  609. })
  610. },
  611. feedNameSearch(queryString, cb) {
  612. this.create.getfeedNameParm.parammaps['fname'] = queryString
  613. GetDataByName(this.create.getfeedNameParm).then(response => {
  614. console.log('模糊查询搜索data', response.data.list)
  615. if (response.data.list == null) {
  616. cb([])
  617. } else {
  618. cb(response.data.list)
  619. }
  620. })
  621. },
  622. handleSelectFeedName(item) {
  623. console.log('模糊查询选中值', item)
  624. this.create.createTemp.feedname = item.fname
  625. this.create.createTemp.feedid = item.id
  626. this.create.createTemp.startweight = item.stockweight
  627. this.create.createTemp.priceold = item.price
  628. this.create.createTemp.providerid = ''
  629. this.create.createTemp.providername = ''
  630. this.create.createTemp.contractcode = ''
  631. this.create.createTemp.pricenew = ''
  632. this.create.createTemp.sumprice = ''
  633. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  634. this.getContractNoList()
  635. }
  636. },
  637. blurFeedName() {
  638. this.create.createTemp.feedname = ''
  639. this.create.createTemp.feedid = ''
  640. this.create.createTemp.startweight = ''
  641. this.create.createTemp.priceold = ''
  642. this.create.createTemp.providerid = ''
  643. this.create.createTemp.providername = ''
  644. this.create.createTemp.contractcode = ''
  645. this.create.createTemp.pricenew = ''
  646. this.create.createTemp.sumprice = ''
  647. },
  648. // 入库重量
  649. blurOperateweight() {
  650. // 毛重grossweight皮重tareweight入库重量operateweight
  651. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  652. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight), 2)
  653. }
  654. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  655. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  656. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  657. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  658. }
  659. }
  660. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  661. if (this.create.createTemp.operateweight == '') {
  662. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  663. }
  664. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  665. this.create.createTemp.tareweight = formatNum(this.create.createTemp.grossweight, 2)
  666. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  667. }
  668. }
  669. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  670. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  671. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  672. } else {
  673. this.create.createTemp.sumprice = ''
  674. }
  675. },
  676. // 毛重
  677. blurGrossweight() {
  678. // 毛重grossweight皮重tareweight入库重量operateweight
  679. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  680. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight), 2)
  681. }
  682. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  683. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  684. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  685. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  686. }
  687. }
  688. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  689. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  690. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  691. } else {
  692. this.create.createTemp.sumprice = ''
  693. }
  694. },
  695. // 皮重
  696. blurTareweight() {
  697. // 毛重grossweight皮重tareweight入库重量operateweight
  698. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.tareweight !== '') {
  699. this.create.createTemp.grossweight = formatNum(parseFloat(this.create.createTemp.tareweight) + parseFloat(this.create.createTemp.operateweight), 2)
  700. }
  701. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  702. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  703. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  704. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  705. }
  706. }
  707. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  708. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  709. this.create.createTemp.tareweight = formatNum(this.create.createTemp.grossweight, 2)
  710. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  711. } else {
  712. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  713. }
  714. }
  715. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  716. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  717. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  718. } else {
  719. this.create.createTemp.sumprice = ''
  720. }
  721. },
  722. // 单价
  723. blurPricenew() {
  724. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  725. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  726. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  727. } else {
  728. this.create.createTemp.sumprice = ''
  729. }
  730. },
  731. // 总价
  732. blurSumprice() {
  733. if (this.create.createTemp.sumprice !== '' && this.create.createTemp.pricenew !== '') {
  734. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.sumprice) / parseFloat(this.create.createTemp.pricenew), 2)
  735. } else {
  736. this.create.createTemp.operateweight = ''
  737. }
  738. },
  739. handleCreate() {
  740. console.log('点击了新增入库单')
  741. this.dialogFull = false
  742. this.create.dialogStatus = 'create'
  743. this.create.dialogFormVisible = true
  744. this.$nextTick(() => {
  745. this.resetCreateTemp()
  746. this.$refs.createTemp.resetFields()
  747. })
  748. },
  749. createData() {
  750. this.$refs['createTemp'].validate(valid => {
  751. if (valid) {
  752. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  753. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  754. return false
  755. }
  756. if (this.create.createTemp.sumprice.length > 15) {
  757. this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
  758. }
  759. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  760. // 入库重量
  761. if (this.create.createTemp.operateweight !== '') {
  762. if (this.create.createTemp.operateweight == 0) {
  763. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  764. return false
  765. } else {
  766. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  767. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  768. return false
  769. }
  770. }
  771. }
  772. // 单价
  773. if (this.create.createTemp.pricenew == 0) {
  774. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  775. return false
  776. } else {
  777. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  778. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  779. return false
  780. }
  781. }
  782. // 总价
  783. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  784. if (this.create.createTemp.sumprice == 0) {
  785. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  786. return false
  787. } else {
  788. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  789. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  790. return false
  791. }
  792. }
  793. }
  794. // 毛重
  795. if (this.create.createTemp.grossweight !== '') {
  796. if (this.create.createTemp.grossweight == 0) {
  797. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  798. return false
  799. } else {
  800. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  801. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  802. return false
  803. }
  804. }
  805. }
  806. // 皮重
  807. if (this.create.createTemp.tareweight !== '') {
  808. if (this.create.createTemp.tareweight == 0) {
  809. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  810. return false
  811. } else {
  812. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  813. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  814. return false
  815. }
  816. }
  817. }
  818. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  819. }).then(() => {
  820. this.isokDisable = true
  821. setTimeout(() => {
  822. this.isokDisable = false
  823. }, 1000)
  824. this.requestParam.common = { 'returnmap': '0' }
  825. this.requestParam.data = []
  826. this.requestParam.data[0] = { 'name': 'insertFeedlaid', 'type': 'e', 'parammaps': {
  827. 'pastureid': this.create.createTemp.pastureid,
  828. 'laiddate': this.create.createTemp.laiddate,
  829. 'feedid': this.create.createTemp.feedid,
  830. 'feedname': this.create.createTemp.feedname,
  831. 'providerid': this.create.createTemp.providerid,
  832. 'providername': this.create.createTemp.providername,
  833. 'contractcode': this.create.createTemp.contractcode,
  834. 'operateweight': this.create.createTemp.operateweight,
  835. 'grossweight': this.create.createTemp.grossweight,
  836. 'tareweight': this.create.createTemp.tareweight,
  837. 'sumprice': this.create.createTemp.sumprice,
  838. 'licence': this.create.createTemp.licence,
  839. 'pcpde': this.create.createTemp.pcpde,
  840. 'remark': this.create.createTemp.remark,
  841. 'createdate': this.create.createTemp.createdate,
  842. 'createemp': this.create.createTemp.createemp,
  843. 'startweight': this.create.createTemp.startweight,
  844. 'priceold': this.create.createTemp.priceold,
  845. 'pricenew': this.create.createTemp.pricenew,
  846. 'wagonnumber': this.create.createTemp.wagonnumber
  847. }}
  848. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  849. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  850. 'operateweight': this.create.createTemp.operateweight,
  851. 'pastureid': this.create.createTemp.pastureid,
  852. 'feedid': this.create.createTemp.feedid,
  853. 'fname': this.create.createTemp.fname,
  854. 'pcpde': this.create.createTemp.pcpde,
  855. 'stockweight': this.create.createTemp.startweight,
  856. 'price': this.create.createTemp.pricenew
  857. }}
  858. }
  859. console.log('点击了新增入库单保存', this.requestParam)
  860. ExecDataByConfig(this.requestParam).then(response => {
  861. if (response.msg === 'fail') {
  862. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  863. } else {
  864. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  865. this.create.dialogFormVisible = false
  866. this.getList()
  867. }
  868. })
  869. })
  870. }
  871. })
  872. },
  873. handleUpdate(row) {
  874. console.log('点击了编辑')
  875. this.$nextTick(() => {
  876. this.$refs.createTemp.resetFields()
  877. })
  878. this.dialogFull = false
  879. this.create.dialogStatus = 'update'
  880. this.create.dialogFormVisible = true
  881. row.feedid = String(row.feedid)
  882. if (row.providerid == -1) {
  883. row.providerid = ''
  884. row.providername = ''
  885. }
  886. this.create.createTemp = Object.assign({}, row)
  887. },
  888. updateData() {
  889. this.$refs['createTemp'].validate(valid => {
  890. if (valid) {
  891. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  892. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  893. return false
  894. }
  895. if (this.create.createTemp.sumprice.length > 15) {
  896. this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
  897. }
  898. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  899. // 入库重量
  900. if (this.create.createTemp.operateweight !== '') {
  901. if (this.create.createTemp.operateweight == 0) {
  902. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  903. return false
  904. } else {
  905. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  906. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  907. return false
  908. }
  909. }
  910. }
  911. // 单价
  912. if (this.create.createTemp.pricenew == 0) {
  913. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  914. return false
  915. } else {
  916. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  917. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  918. return false
  919. }
  920. }
  921. // 总价
  922. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  923. if (this.create.createTemp.sumprice == 0) {
  924. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  925. return false
  926. } else {
  927. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  928. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  929. return false
  930. }
  931. }
  932. }
  933. // 毛重
  934. if (this.create.createTemp.grossweight !== '') {
  935. if (this.create.createTemp.grossweight == 0) {
  936. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  937. return false
  938. } else {
  939. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  940. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  941. return false
  942. }
  943. }
  944. }
  945. // 皮重
  946. if (this.create.createTemp.tareweight !== '') {
  947. if (this.create.createTemp.tareweight == 0) {
  948. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  949. return false
  950. } else {
  951. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  952. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  953. return false
  954. }
  955. }
  956. }
  957. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  958. }).then(() => {
  959. this.isokDisable = true
  960. setTimeout(() => {
  961. this.isokDisable = false
  962. }, 1000)
  963. this.requestParam.common = { 'returnmap': '0' }
  964. this.requestParam.data = []
  965. this.requestParam.data[0] = { 'name': 'updateFeedlaid', 'type': 'e', 'parammaps': {
  966. 'pastureid': this.create.createTemp.pastureid,
  967. 'id': this.create.createTemp.id,
  968. 'laiddate': this.create.createTemp.laiddate,
  969. 'feedid': this.create.createTemp.feedid,
  970. 'feedname': this.create.createTemp.feedname,
  971. 'providerid': this.create.createTemp.providerid,
  972. 'providername': this.create.createTemp.providername,
  973. 'contractcode': this.create.createTemp.contractcode,
  974. 'operateweight': this.create.createTemp.operateweight,
  975. 'grossweight': this.create.createTemp.grossweight,
  976. 'tareweight': this.create.createTemp.tareweight,
  977. 'sumprice': this.create.createTemp.sumprice,
  978. 'licence': this.create.createTemp.licence,
  979. 'pcpde': this.create.createTemp.pcpde,
  980. 'remark': this.create.createTemp.remark,
  981. 'createdate': this.create.createTemp.createdate,
  982. 'createemp': this.create.createTemp.createemp,
  983. 'startweight': this.create.createTemp.startweight,
  984. 'priceold': this.create.createTemp.priceold,
  985. 'pricenew': this.create.createTemp.pricenew,
  986. 'wagonnumber': this.create.createTemp.wagonnumber
  987. }}
  988. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  989. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  990. 'operateweight': this.create.createTemp.operateweight,
  991. 'pastureid': this.create.createTemp.pastureid,
  992. 'feedid': this.create.createTemp.feedid,
  993. 'fname': this.create.createTemp.fname,
  994. 'pcpde': this.create.createTemp.pcpde,
  995. 'stockweight': this.create.createTemp.startweight,
  996. 'price': this.create.createTemp.pricenew
  997. }}
  998. }
  999. console.log('点击了新增入库单保存', this.requestParam)
  1000. ExecDataByConfig(this.requestParam).then(response => {
  1001. if (response.msg === 'fail') {
  1002. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1003. } else {
  1004. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  1005. this.create.dialogFormVisible = false
  1006. this.getList()
  1007. }
  1008. })
  1009. })
  1010. }
  1011. })
  1012. },
  1013. form_see(row) {
  1014. console.log('点击了查看')
  1015. this.$nextTick(() => {
  1016. this.$refs.createTemp.resetFields()
  1017. })
  1018. this.dialogFull = false
  1019. this.create.dialogStatus = 'see'
  1020. this.create.dialogFormVisible = true
  1021. if (row.providerid == -1) {
  1022. row.providerid = ''
  1023. row.providername = ''
  1024. }
  1025. this.create.createTemp = Object.assign({}, row)
  1026. },
  1027. handleInitial() {
  1028. console.log('点击了初始化库存')
  1029. this.dialogFull = false
  1030. this.initial.dialogStatus = 'initial'
  1031. this.initial.dialogFormVisible = true
  1032. this.getInitialList()
  1033. },
  1034. getInitialList() {
  1035. this.initial.listLoading = true
  1036. GetDataByName(this.initial.getdataListParm).then(response => {
  1037. console.log('table数据', response.data.list)
  1038. if (response.data.list !== null) {
  1039. this.initial.list = response.data.list
  1040. this.initial.pageNum = response.data.pageNum
  1041. this.initial.pageSize = response.data.pageSize
  1042. this.initial.total = response.data.total
  1043. } else {
  1044. this.initial.list = []
  1045. }
  1046. setTimeout(() => {
  1047. this.initial.listLoading = false
  1048. }, 100)
  1049. })
  1050. },
  1051. handleInitialExport() {
  1052. console.log('点击了初始化库存导出')
  1053. const ExcelDatas = [
  1054. {
  1055. tHeader: ['饲料名称', '库存重量'],
  1056. filterVal: ['fname', 'stockweight'],
  1057. tableDatas: this.initial.list,
  1058. sheetName: '初始化库存'
  1059. }
  1060. ]
  1061. json2excel(ExcelDatas, '初始化库存', true, 'xlsx')
  1062. },
  1063. async handleInitialImport(eve) {
  1064. const file = eve.raw
  1065. if (!file) return
  1066. let reader = await upload(file)
  1067. const worker = xlsx.read(reader, { type: 'binary' })
  1068. // 将返回的数据转换为json对象的数据
  1069. reader = xlsx.utils.sheet_to_json(worker.Sheets[worker.SheetNames[0]])
  1070. console.log(reader)
  1071. const arr = []
  1072. reader.forEach(item => {
  1073. const obj = {}
  1074. for (const key in this.initial.character) {
  1075. if (!this.initial.character.hasOwnProperty(key)) break
  1076. let v = this.initial.character[key]
  1077. const text = v.text
  1078. const type = v.type
  1079. v = item[text] || ''
  1080. type === 'string' ? (v = String(v)) : null
  1081. type === 'number' ? (v = Number(v)) : null
  1082. obj[key] = v
  1083. }
  1084. arr.push(obj)
  1085. })
  1086. console.log('导入处理后数据', arr)
  1087. var sum = 0
  1088. for (let i = 0; i < this.initial.list.length; i++) {
  1089. for (let j = 0; j < arr.length; j++) {
  1090. if (this.initial.list[i].fname == arr[j].fname) {
  1091. this.initial.list[i].stockweight = arr[j].stockweight
  1092. sum++
  1093. arr.splice(j, 1)
  1094. }
  1095. }
  1096. }
  1097. console.log(arr)
  1098. for (let i = 0; i < arr.length; i++) {
  1099. this.$set(arr[i], 'msg', '饲料名称与系统不匹配')
  1100. }
  1101. console.log(sum)
  1102. this.$message({ title: '成功', message: '导入成功:' + sum + '条!', type: 'success', duration: 2000 })
  1103. this.$notify({ title: '失败', message: '导入失败:' + arr.length + '条!', type: 'danger', duration: 2000 })
  1104. if (arr.length > 0) {
  1105. const ExcelDatas1 = [
  1106. {
  1107. tHeader: ['饲料名称', '库存重量', '报错信息'],
  1108. filterVal: ['fname', 'stockweight', 'msg'],
  1109. tableDatas: arr,
  1110. sheetName: 'ExcelDatas1'
  1111. }
  1112. ]
  1113. json2excel(ExcelDatas1, '初始化库存报错信息', true, 'xlsx')
  1114. }
  1115. },
  1116. initialData() {
  1117. console.log('点击了初始化库存保存')
  1118. this.isokDisable = true
  1119. setTimeout(() => {
  1120. this.isokDisable = false
  1121. }, 1000)
  1122. var rulesStockweight = /^\d+(\.\d{1,2})?$/
  1123. for (let i = 0; i < this.initial.list.length; i++) {
  1124. if (!rulesStockweight.test(parseFloat(this.initial.list[i].stockweight))) {
  1125. this.$message({ type: 'warning', message: '库存重量不可小于0,且保留俩位小数', duration: 2000 })
  1126. return false
  1127. }
  1128. }
  1129. this.requestParam.common = { 'returnmap': '0' }
  1130. this.requestParam.data = []
  1131. this.requestParam.data[0] = { 'name': 'clearFS', 'type': 'e', 'parammaps': {
  1132. 'pastureid': Cookies.get('pastureid')
  1133. }}
  1134. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.initial.list }}
  1135. this.requestParam.data[1].children = []
  1136. this.requestParam.data[1].children[0] = { 'name': 'insertFeedstorage', 'type': 'e', 'parammaps': {
  1137. pastureid: '@insertSpotList.pastureid',
  1138. feedid: '@insertSpotList.feedid',
  1139. fname: '@insertSpotList.fname',
  1140. pcpde: '@insertSpotList.pcpde',
  1141. stockweight: '@insertSpotList.stockweight',
  1142. price: '@insertSpotList.price'
  1143. }}
  1144. ExecDataByConfig(this.requestParam).then(response => {
  1145. if (response.msg === 'fail') {
  1146. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1147. } else {
  1148. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  1149. this.create.dialogFormVisible = false
  1150. this.getList()
  1151. }
  1152. })
  1153. },
  1154. // 导出
  1155. handleExport(item) {
  1156. if (item == 1) {
  1157. console.log('点击了导出模板')
  1158. const requestParam = this.requestParam
  1159. const url = Cookies.get('url') + 'file/导入导出模板/库存管理/入库导入模板.xlsx' // 请求下载文件的地址
  1160. console.log(url)
  1161. axios({
  1162. method: 'GET',
  1163. url: url,
  1164. data: requestParam,
  1165. headers: { token: getToken(), optname: 'insertcustomdoc' },
  1166. responseType: 'blob'
  1167. }).then(res => {
  1168. if (!res) return
  1169. this.percentage = 99
  1170. setTimeout(() => {
  1171. this.isPercentage = false
  1172. }, 2000)
  1173. const blob = new Blob([res.data], {
  1174. type: 'application/octet-stream;charset=utf-8'
  1175. })
  1176. const url = window.URL.createObjectURL(blob)
  1177. const aLink = document.createElement('a')
  1178. aLink.style.display = 'none'
  1179. aLink.href = url
  1180. const docname = '入库管理导入模板.xlsx'
  1181. aLink.setAttribute('download', docname) // 下载的文件
  1182. document.body.appendChild(aLink)
  1183. aLink.click()
  1184. document.body.removeChild(aLink)
  1185. window.URL.revokeObjectURL(url)
  1186. })
  1187. } else {
  1188. console.log('点击了导出数据')
  1189. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1190. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  1191. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  1192. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  1193. } else {
  1194. this.download.getdataListParm.parammaps.inputDatetime = ''
  1195. this.download.getdataListParm.parammaps.startTime = ''
  1196. this.download.getdataListParm.parammaps.stopTime = ''
  1197. }
  1198. GetDataByName(this.download.getdataListParm).then(response => {
  1199. if (response.data.list !== null) {
  1200. this.download.list = response.data.list
  1201. } else {
  1202. this.download.list = []
  1203. }
  1204. var excelDatas = [
  1205. {
  1206. tHeader: ['入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注'],
  1207. filterVal: ['laiddate', 'wagonnumber', 'feedname', 'providername', 'contractcode', 'operateweight', 'pricenew', 'sumprice', 'grossweight', 'tareweight', 'licence', 'pcpde', 'createemp', 'createdate', 'remark'],
  1208. tableDatas: this.download.list,
  1209. sheetName: 'Sheet1'
  1210. }
  1211. ]
  1212. json2excel(excelDatas, '入库管理', true, 'xlsx')
  1213. })
  1214. }
  1215. },
  1216. beforeImport(file) {
  1217. const isLt2M = file.size / 1024 / 1024 < 2
  1218. if (!isLt2M) {
  1219. this.$message.error('上传文件大小不能超过 2MB!')
  1220. }
  1221. return isLt2M
  1222. },
  1223. handleImportSuccess(res, file) {
  1224. this.getList()
  1225. if (res.msg === 'ok') {
  1226. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1227. if (res.data.err_count > 0) {
  1228. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1229. import('@/vendor/Export2Excel').then(excel => {
  1230. const list1 = res.data.result
  1231. const tHeader = [
  1232. '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', '错误信息'
  1233. ]
  1234. const filterVal = [
  1235. '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', 'error_msg'
  1236. ]
  1237. const data1 = this.formatJson(filterVal, list1)
  1238. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '入库管理导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1239. })
  1240. }
  1241. } else {
  1242. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1243. }
  1244. },
  1245. formatJson(filterVal, jsonData) {
  1246. return jsonData.map(v =>
  1247. filterVal.map(j => {
  1248. if (j === 'timestamp') {
  1249. return parseTime(v[j])
  1250. } else {
  1251. return v[j]
  1252. }
  1253. })
  1254. )
  1255. }
  1256. }
  1257. }
  1258. </script>