7e58ddd969e4b88688f29bdf63697ee5ec0ac93f.svn-base 55 KB

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