index改.vue 62 KB

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