stockInOrder.vue 42KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <!--<bread-crumb :crumbs='crumbs'></bread-crumb>-->
  5. <bread-crumb :crumbs="crumbs"></bread-crumb>
  6. <el-button
  7. size="small"
  8. @click="handleWarehouse"
  9. class="filter-item"
  10. style="float:right;"
  11. type="primary"
  12. icon="el-icon-circle-plus-outline"
  13. >新增</el-button
  14. >
  15. </div>
  16. <div class="app-container">
  17. <div class="cell clearfix">
  18. <el-input
  19. size="small"
  20. style="width: 400px;"
  21. v-model.trim="searchKey"
  22. class="filter-item"
  23. placeholder="单据编码/制单人/厂商"
  24. />
  25. <el-button
  26. size="small"
  27. class="filter-item"
  28. type="primary"
  29. icon="el-icon-search"
  30. @click="search"
  31. >搜索</el-button
  32. >
  33. </div>
  34. <div class="cell clearfix">
  35. <label class="title"><span class="name">入库时间</span> : </label>
  36. <el-date-picker
  37. size="small"
  38. v-model="start_time"
  39. prefix-icon="el-icon-date"
  40. :editable="false"
  41. style="width: 196px;"
  42. type="date"
  43. placeholder="选择日期时间"
  44. align="right"
  45. format="yyyy-MM-dd"
  46. value-format="yyyy-MM-dd"
  47. @change="startTimeChange"
  48. ></el-date-picker>
  49. <span class="cellLine"> - </span>
  50. <el-date-picker
  51. size="small"
  52. v-model="end_time"
  53. prefix-icon="el-icon-date"
  54. :editable="false"
  55. style="width: 196px;"
  56. type="date"
  57. placeholder="选择日期时间"
  58. align="right"
  59. format="yyyy-MM-dd"
  60. value-format="yyyy-MM-dd"
  61. @change="endTimeChange"
  62. ></el-date-picker>
  63. </div>
  64. <div class="cell clearfix">
  65. <el-checkbox
  66. style="width: 70px"
  67. v-model="checked"
  68. @change="changeAllSelected"
  69. >全选</el-checkbox
  70. >
  71. <el-button size="small" icon="el-icon-delete" @click="batchDelete"
  72. >删除</el-button
  73. >
  74. </div>
  75. <el-table
  76. :data="Warehouse.warehouseDate"
  77. :class="signAndWeighBoxPatients"
  78. style="width: 100%"
  79. border
  80. highlight-current-row
  81. v-loading="Warehouse.loading"
  82. ref="multipleTable"
  83. @selection-change="select"
  84. :row-style="{ color: '#303133' }"
  85. :header-cell-style="{
  86. backgroundColor: 'rgb(245, 247, 250)',
  87. color: '#606266'
  88. }"
  89. >
  90. <el-table-column align="center" type="selection" width="55">
  91. </el-table-column>
  92. <el-table-column label="单据日期" align="center">
  93. <template slot-scope="scope">
  94. {{ scope.row.warehousing_time | parseTime("{y}-{m}-{d}") }}
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="单据编号" align="center">
  98. <template slot-scope="scope">
  99. {{ scope.row.warehousing_order }}
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="制单人" align="center">
  103. <template slot-scope="scope">
  104. {{ getXuserName(scope.row.creater) }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="厂家" align="center">
  108. <template slot-scope="scope">
  109. {{ getManufactuerName(scope.row.manufacturer) }}
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="经销商" align="center">
  113. <template slot-scope="scope">
  114. {{ getDealerName(scope.row.dealer) }}
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="操作" align="center" width="260px">
  118. <template slot-scope="scope">
  119. <el-tooltip
  120. class="item"
  121. effect="dark"
  122. content="详情"
  123. placement="top"
  124. >
  125. <el-button
  126. size="small"
  127. type="primary"
  128. icon="el-icon-search"
  129. @click="handleSearch(scope.row.id)"
  130. >
  131. </el-button>
  132. </el-tooltip>
  133. <el-tooltip
  134. class="item"
  135. effect="dark"
  136. content="编辑"
  137. placement="top"
  138. >
  139. <el-button
  140. size="small"
  141. type="primary"
  142. icon="el-icon-edit-outline"
  143. @click="handleEdit(scope.$index, scope.row)"
  144. >
  145. </el-button>
  146. </el-tooltip>
  147. <el-tooltip
  148. class="item"
  149. effect="dark"
  150. content="删除"
  151. placement="top"
  152. >
  153. <el-button
  154. size="small"
  155. type="danger"
  156. icon="el-icon-delete"
  157. @click="handleDelete(scope.$index, scope.row)"
  158. >
  159. </el-button>
  160. </el-tooltip>
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. <el-pagination
  165. @size-change="handleSizeChange"
  166. @current-change="handleCurrentChange"
  167. :page-sizes="[10, 50, 100]"
  168. :page-size="10"
  169. background
  170. style="margin-top:20px;float: right"
  171. layout="total, sizes, prev, pager, next, jumper"
  172. :total="total"
  173. >
  174. </el-pagination>
  175. </div>
  176. <el-dialog
  177. title="详情"
  178. :visible.sync="dialogVisible"
  179. width="80%"
  180. >
  181. <span>
  182. <div>
  183. <el-row>
  184. <span style="font-size: 18px;color: #606266">入库单详情</span>
  185. </el-row>
  186. <el-row style="float:left;">
  187. <span style="color: #606266"
  188. >入库单号: {{ WarehouseInfo.warehouse.warehousing_order }}</span
  189. >
  190. </el-row>
  191. </div>
  192. <div class="cell clearfix">
  193. <span style="width: 300px;color: #606266;float:right">单据日期:{{ WarehouseInfo.warehouse.warehousing_time | parseTime("{y}-{m}-{d}")}} </span>
  194. <span style="width: 300px;color: #606266;float:right">厂商:{{ getManufactuerName(WarehouseInfo.warehouse.manufacturer) }}</span>
  195. <span style="width: 300px;color: #606266"
  196. >经销商:{{ getDealerName(WarehouseInfo.warehouse.dealer) }} </span>
  197. </div>
  198. <div class="cell clearfix" style="margin-top: 10px">
  199. <el-button size="small" icon="el-icon-edit" @click="editRecord"
  200. >编辑</el-button
  201. >
  202. <el-button size="small" icon="el-icon-delete" @click="deleteRecord"
  203. >删除</el-button
  204. >
  205. <el-row :gutter="12" style="margin-top: 10px">
  206. <el-table
  207. :data="WarehouseInfo.warehouseInfoDate"
  208. :class="signAndWeighBoxPatients"
  209. style="width: 100%"
  210. border
  211. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  212. >
  213. <el-table-column min-width="35" align="center">
  214. <template slot="header" slot-scope="scope">
  215. <span>商品类型</span>
  216. </template>
  217. <template slot-scope="scope">
  218. <span v-if="scope.row.good_type_id != 0">{{
  219. getTypeName(scope.row.good_type_id)
  220. }}</span>
  221. </template>
  222. </el-table-column>
  223. <el-table-column min-width="35" align="center">
  224. <template slot="header" slot-scope="scope">
  225. <span>规格名称</span>
  226. </template>
  227. <template slot-scope="scope">
  228. <span v-if="scope.row.good_id != 0">{{
  229. getSpecificationName(scope.row.good_id)
  230. }}</span>
  231. </template>
  232. </el-table-column>
  233. <el-table-column min-width="23" align="center">
  234. <template slot="header" slot-scope="scope">
  235. <span>单价</span>
  236. </template>
  237. <template slot-scope="scope">
  238. <span>{{ scope.row.price }}</span>
  239. </template>
  240. </el-table-column>
  241. <el-table-column min-width="23" align="center">
  242. <template slot="header" slot-scope="scope">
  243. <span>入库数量</span>
  244. </template>
  245. <template slot-scope="scope">
  246. <span>{{ scope.row.warehousing_count }}</span>
  247. </template>
  248. </el-table-column>
  249. <el-table-column label="总价" min-width="20" align="center">
  250. <template slot-scope="scope">
  251. {{ calculate(scope.row.price * scope.row.warehousing_count) }}
  252. </template>
  253. </el-table-column>
  254. <el-table-column align="center" min-width="25">
  255. <template slot="header" slot-scope="scope">
  256. <span>批号</span>
  257. </template>
  258. <template slot-scope="scope">
  259. <span>{{ scope.row.number }}</span>
  260. </template>
  261. </el-table-column>
  262. <el-table-column label="生产日期" min-width="40" align="center">
  263. <template v-if="scope.row.product_date != 0" slot-scope="scope">
  264. {{ scope.row.product_date }}
  265. </template>
  266. </el-table-column>
  267. <el-table-column label="有效日期" min-width="40" align="center">
  268. <template v-if="scope.row.expiry_date != 0" slot-scope="scope">
  269. {{ scope.row.expiry_date }}
  270. </template>
  271. </el-table-column>
  272. <el-table-column label="备注" min-width="20" align="center">
  273. <template slot-scope="scope">
  274. <el-popover placement="top-start" width="250" trigger="hover">
  275. <div>{{ scope.row.remark }}</div>
  276. <span slot="reference" v-if="scope.row.remark.length > 20">{{
  277. scope.row.remark.substr(0, 20) + "..."
  278. }}</span>
  279. <span slot="reference" v-else>{{ scope.row.remark }}</span>
  280. </el-popover>
  281. </template>
  282. </el-table-column>
  283. </el-table>
  284. </el-row>
  285. </div>
  286. </span>
  287. <span slot="footer" class="dialog-footer">
  288. <el-button @click="dialogVisible = false">取 消</el-button>
  289. <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  290. </span>
  291. </el-dialog>
  292. <el-dialog
  293. title="新增"
  294. :visible.sync="editDialogVisible"
  295. width="80%"
  296. >
  297. <span>
  298. <div style="margin-bottom:10px">
  299. <label class="title"><span class="name">入库时间</span> : </label>
  300. <el-date-picker size="small" v-model="warehousing_time" prefix-icon="el-icon-date" :editable="false"
  301. style="width: 196px;" type="date" placeholder="选择日期时间" align="right" format="yyyy-MM-dd"
  302. value-format="yyyy-MM-dd"></el-date-picker>
  303. </div>
  304. <div style="margin-bottom:10px">
  305. <label class="title"><span class="name">经 销 商</span> : </label>
  306. <el-select size="small" v-model="form.dealer" clearable placeholder="请选择经销商" @change="changeDealer">
  307. <el-option
  308. v-for="(option, index) in dealer"
  309. :key="index"
  310. :label="option.dealer_name"
  311. :value="option.id">
  312. </el-option>
  313. </el-select>
  314. </div>
  315. <div style="margin-bottom:10px">
  316. <label class="title"><span class="name">厂商</span> : </label>
  317. <el-select size="small" v-model="form.manufacturer" clearable placeholder="请选择厂商"
  318. @change="changeManufacturer">
  319. <el-option
  320. v-for="(option, index) in manufacturer"
  321. :key="index"
  322. :label="option.manufacturer_name"
  323. :value="option.id">
  324. </el-option>
  325. </el-select>
  326. </div>
  327. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  328. <el-table
  329. id="oictable"
  330. :data="recordInfo.recordData"
  331. :class="signAndWeighBoxPatients"
  332. style="width: 100%"
  333. border
  334. max-height="450"
  335. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  336. >
  337. <el-table-column align="center" width="200">
  338. <template slot="header" slot-scope="scope">
  339. <span>商品类型<span style="color: red">*</span></span>
  340. </template>
  341. <template slot-scope="scope">
  342. <el-form-item style="padding-top: 15px">
  343. <el-input
  344. placeholder="请输入商品类型"
  345. v-model="scope.row.good_type_id"
  346. :value="typeName(scope.row.good_type_id)"
  347. @focus="showDialog(scope.$index, scope.row)"
  348. ></el-input>
  349. </el-form-item>
  350. </template>
  351. </el-table-column>
  352. <el-table-column align="center" width="200">
  353. <template slot="header" slot-scope="scope">
  354. <span>规格名称<span style="color: red">*</span></span>
  355. </template>
  356. <template slot-scope="scope">
  357. <el-form-item style="padding-top: 15px">
  358. <el-input
  359. placeholder="请输入规格名称"
  360. v-model="scope.row.good_id"
  361. :value="specificationName(scope.row.good_id)"
  362. @focus="showDialog(scope.$index, scope.row)"
  363. ></el-input>
  364. </el-form-item>
  365. </template>
  366. </el-table-column>
  367. <el-table-column align="center" width="150">
  368. <template slot="header" slot-scope="scope">
  369. <span>单价<span style="color: red">*</span></span>
  370. </template>
  371. <template slot-scope="scope">
  372. <!--<el-input type="number" v-model="scope.row.price" @blur="handleBlur(scope.$index, scope.row)"></el-input>-->
  373. <el-form-item
  374. :prop="'recordData.' + scope.$index + '.price'"
  375. :rules="tableRules.price"
  376. style="padding-top: 17px"
  377. >
  378. <el-input
  379. placeholder="请输入单价"
  380. type="number"
  381. v-model="scope.row.price"
  382. ></el-input>
  383. </el-form-item>
  384. </template>
  385. </el-table-column>
  386. <el-table-column align="center" width="180">
  387. <template slot="header" slot-scope="scope">
  388. <span>入库数量<span style="color: red">*</span></span>
  389. </template>
  390. <template slot-scope="scope">
  391. <!--{{scope.row.warehousing_count}}-->
  392. <!--<el-input type="number" v-model="scope.row.warehousing_count" @blur="handleBlur(scope.$index, scope.row)"></el-input>-->
  393. <el-form-item
  394. :prop="'recordData.' + scope.$index + '.warehousing_count'"
  395. :rules="tableRules.warehousing_count"
  396. style="padding-top: 17px"
  397. >
  398. <el-input
  399. placeholder="请输入入库数量"
  400. type="number"
  401. v-model="scope.row.warehousing_count"
  402. ></el-input>
  403. </el-form-item>
  404. </template>
  405. </el-table-column>
  406. <el-table-column label="总价" align="center" width="150">
  407. <template slot-scope="scope">
  408. {{ calculate(scope.row.price * scope.row.warehousing_count) }}
  409. </template>
  410. </el-table-column>
  411. <el-table-column align="center" width="150">
  412. <template slot="header" slot-scope="scope">
  413. <span>批号</span>
  414. </template>
  415. <template slot-scope="scope">
  416. <el-form-item>
  417. <el-input
  418. placeholder="请输入批号"
  419. v-model="scope.row.number"
  420. ></el-input>
  421. </el-form-item>
  422. </template>
  423. </el-table-column>
  424. <el-table-column label="生产日期" width="250" align="center">
  425. <template slot-scope="scope">
  426. <el-date-picker
  427. prefix-icon="el-icon-date"
  428. style="width: 145px"
  429. v-model="scope.row.product_date"
  430. type="date"
  431. placeholder="选择日期时间"
  432. format="yyyy-MM-dd"
  433. value-format="yyyy-MM-dd"
  434. ></el-date-picker>
  435. </template>
  436. </el-table-column>
  437. <el-table-column label="有效日期" width="250" align="center">
  438. <template slot-scope="scope">
  439. <el-date-picker
  440. prefix-icon="el-icon-date"
  441. style="width: 145px"
  442. v-model="scope.row.expiry_date"
  443. type="date"
  444. placeholder="选择日期时间"
  445. format="yyyy-MM-dd"
  446. value-format="yyyy-MM-dd"
  447. ></el-date-picker>
  448. </template>
  449. </el-table-column>
  450. <el-table-column label="备注" width="150" align="center">
  451. <template slot-scope="scope">
  452. <el-input v-model="scope.row.remark"></el-input>
  453. </template>
  454. </el-table-column>
  455. <el-table-column
  456. label="操作"
  457. fixed="right"
  458. align="center"
  459. width="150"
  460. >
  461. <template slot-scope="scope">
  462. <el-tooltip
  463. class="item"
  464. effect="dark"
  465. content="新增"
  466. placement="top"
  467. >
  468. <el-button
  469. size="mini"
  470. type="primary"
  471. icon="el-icon-circle-plus-outline"
  472. @click="handleEditTwo(scope.$index, scope.row)"
  473. >
  474. </el-button>
  475. </el-tooltip>
  476. <el-tooltip
  477. class="item"
  478. effect="dark"
  479. content="删除"
  480. placement="top"
  481. >
  482. <el-button
  483. size="mini"
  484. type="danger"
  485. icon="el-icon-delete"
  486. @click="DeleteWarehouseInfoItem(scope.$index, scope.row)"
  487. >
  488. </el-button>
  489. </el-tooltip>
  490. </template>
  491. </el-table-column>
  492. </el-table>
  493. </el-form>
  494. </span>
  495. <span slot="footer" class="dialog-footer">
  496. <el-button @click="editDialogVisible = false">取 消</el-button>
  497. <el-button type="primary" @click="submit()">保 存</el-button>
  498. </span>
  499. </el-dialog>
  500. <stock-in-dialog
  501. ref="dialog"
  502. :propForm="propForm"
  503. :visibility="isVisibility"
  504. v-on:dialog-comfirm="comfirm"
  505. v-on:dialog-cancle="cancle">
  506. </stock-in-dialog>
  507. </div>
  508. </template>
  509. <script>
  510. import stockInDialog from "./Dialog/stockInDialog";
  511. import { uParseTime } from "@/utils/tools";
  512. import { fetchAllAdminUsers, fetchAllDoctorAndNurse } from "@/api/doctor";
  513. import {
  514. deleteWarehouseInfo,
  515. GetAllConfig,
  516. GetAllGoodInfo,
  517. GetAllGoodType,
  518. getWarehouseInfoList,
  519. getWarehouseList,
  520. DeleteWarehouseInfoItem,
  521. GetAllGoodInfoByID,
  522. EditWarehouse
  523. } from "@/api/stock";
  524. import { GetAllDrugInfoByID,postDrugWarehouse} from "@/api/drug/drug_stock";
  525. import BreadCrumb from "../components/bread-crumb";
  526. export default {
  527. name: "stockIn",
  528. components: { BreadCrumb, stockInDialog },
  529. created() {
  530. var nowDate = new Date();
  531. var nowYear = nowDate.getFullYear();
  532. var nowMonth = nowDate.getMonth() + 1;
  533. var nowDay = nowDate.getDate();
  534. this.end_time =
  535. nowYear +
  536. "-" +
  537. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  538. "-" +
  539. (nowDay < 10 ? "0" + nowDay : nowDay);
  540. nowDate.setMonth(nowDate.getMonth() - 1);
  541. this.start_time =
  542. nowYear +
  543. "-" +
  544. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  545. "-" +
  546. (nowDay < 10 ? "0" + nowDay : nowDay);
  547. this.warehousing_time =
  548. nowYear +
  549. '-' +
  550. (nowMonth < 10 ? '0' + nowMonth : nowMonth) +
  551. '-' +
  552. (nowDay < 10 ? '0' + nowDay : nowDay)
  553. this.GetWarehouse();
  554. this.GetConfigInfo();
  555. this.fetchAllAdminUsers();
  556. this.GetAllGoodType()
  557. this.GetAllGoodInfo()
  558. },
  559. data() {
  560. var checkGoodId = (rule, value, callback) => {
  561. setTimeout(() => {
  562. if (value == "" || value == 0) {
  563. return callback(new Error("规格名称不能为空"));
  564. }
  565. }, 2000);
  566. };
  567. return {
  568. crumbs: [
  569. { path: false, name: "库存管理" },
  570. { path: false, name: "入库单" }
  571. ],
  572. searchKey: "",
  573. type: 1,
  574. page: 1,
  575. limit: 10,
  576. checked: false,
  577. total: 0,
  578. pageTotal: 0,
  579. pageSelect: 0,
  580. adminUserOptions: [],
  581. multipleSelection: [],
  582. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  583. start_time: "",
  584. end_time: "",
  585. goodType: [],
  586. goodInfo: [],
  587. manufacturer: [],
  588. selectedTableData: [],
  589. dealer: [],
  590. Warehouse: {
  591. loading: false,
  592. warehouseDate: [],
  593. tableCurrentIndex: ""
  594. },
  595. WarehouseInfo: {
  596. loading: false,
  597. warehouseInfoDate: [],
  598. warehouse: {}
  599. },
  600. startTime: "",
  601. dialogVisible:false,
  602. editDialogVisible:false,
  603. recordInfo: {
  604. recordData: [],
  605. stock_in_code: "",
  606. current_index: ""
  607. },
  608. tableRules: {
  609. price: [{ required: true, message: "单价不能为空", trigger: "blur" }],
  610. warehousing_count: [
  611. { required: true, message: "数量不能为空", trigge: "blur" }
  612. ],
  613. good_id: [{ validator: checkGoodId, trigger: "blur" }]
  614. },
  615. form: {
  616. manufacturer: '',
  617. dealer: ''
  618. },
  619. dealer: [],
  620. goodType: [],
  621. goodInfo:[],
  622. warehousing_time: '',
  623. propForm: {
  624. goods: [],
  625. goodType: [],
  626. goodInfo: [],
  627. goodUnit: [],
  628. title: '入库',
  629. formValue: {
  630. good_type_id: '',
  631. good_id: '',
  632. number: '',
  633. product_date: '',
  634. expiry_date: '',
  635. warehousing_count: '',
  636. price: '',
  637. remark: '',
  638. dealer: '',
  639. manufacturer: ''
  640. },
  641. isCreated: 1,
  642. isVisibility: false,
  643. drug_id:1
  644. },
  645. };
  646. },
  647. methods: {
  648. search: function() {
  649. const Params = {
  650. page: this.page,
  651. limit: this.limit,
  652. start_time: this.start_time,
  653. end_time: this.end_time,
  654. type: this.type,
  655. keywords: this.searchKey
  656. };
  657. this.Warehouse.warehouseDate = [];
  658. getWarehouseList(Params).then(response => {
  659. if (response.data.state == 0) {
  660. this.Warehouse.loading = false;
  661. this.$message.error(response.data.msg);
  662. return false;
  663. } else {
  664. this.Warehouse.loading = false;
  665. this.total = response.data.data.total;
  666. for (let i = 0; i < response.data.data.list.length; i++) {
  667. this.Warehouse.warehouseDate.push(response.data.data.list[i]);
  668. }
  669. }
  670. });
  671. },
  672. GetWarehouse: function() {
  673. const Params = {
  674. page: this.page,
  675. limit: this.limit,
  676. start_time: this.start_time,
  677. end_time: this.end_time,
  678. type: this.type
  679. };
  680. this.Warehouse.warehouseDate = [];
  681. getWarehouseList(Params).then(response => {
  682. if (response.data.state == 0) {
  683. this.Warehouse.loading = false;
  684. this.$message.error(response.data.msg);
  685. return false;
  686. } else {
  687. this.Warehouse.loading = false;
  688. this.total = response.data.data.total;
  689. for (let i = 0; i < response.data.data.list.length; i++) {
  690. this.Warehouse.warehouseDate.push(response.data.data.list[i]);
  691. }
  692. }
  693. });
  694. },
  695. tableRowClassName({ row, rowIndex }) {
  696. // 把每一行的索引放进row
  697. row.index = rowIndex;
  698. },
  699. onRowClick(row, event, column) {
  700. this.WarehouseInfo.warehouseInfoDate = [];
  701. this.Warehouse.tableCurrentIndex = row.index;
  702. const params = {
  703. id: row.id
  704. };
  705. this.WarehouseInfo.loading = true;
  706. getWarehouseInfoList(params).then(response => {
  707. if (response.data.state == 0) {
  708. this.WarehouseInfo.loading = false;
  709. this.$message.error(response.data.msg);
  710. return false;
  711. } else {
  712. this.WarehouseInfo.loading = false;
  713. for (let i = 0; i < response.data.data.info.length; i++) {
  714. this.WarehouseInfo.warehouseInfoDate.push(response.data.data.info[i]);
  715. }
  716. }
  717. });
  718. },
  719. getXuserName(id) {
  720. if (id <= 0) {
  721. return "";
  722. }
  723. var name = "";
  724. if (
  725. this.adminUserOptions == null ||
  726. typeof this.adminUserOptions.length === "undefined"
  727. ) {
  728. return name;
  729. }
  730. var leng = this.adminUserOptions.length;
  731. if (leng == 0) {
  732. return name;
  733. }
  734. for (let index = 0; index < leng; index++) {
  735. if (this.adminUserOptions[index].id == id) {
  736. name = this.adminUserOptions[index].name;
  737. break;
  738. }
  739. }
  740. return name;
  741. },
  742. fetchAllDoctorAndNurse() {
  743. fetchAllDoctorAndNurse().then(response => {
  744. if (response.data.state == 1) {
  745. this.doctorOptions = response.data.data.doctors;
  746. }
  747. });
  748. },
  749. fetchAllAdminUsers() {
  750. fetchAllAdminUsers().then(response => {
  751. console.log(response);
  752. if (response.data.state == 1) {
  753. this.adminUserOptions = response.data.data.users;
  754. var alen = this.adminUserOptions.length;
  755. for (let index = 0; index < alen; index++) {
  756. if (this.adminUserOptions[index].user_type == 2) {
  757. // this.doctorOptions.push(this.adminUserOptions[index]);
  758. }
  759. }
  760. }
  761. });
  762. },
  763. getSpecificationName: function(id) {
  764. let name = "";
  765. for (let i = 0; i < this.goodInfo.length; i++) {
  766. if (this.goodInfo[i].id == id) {
  767. name = this.goodInfo[i].specification_name;
  768. }
  769. }
  770. return name;
  771. },
  772. getTypeName: function(id) {
  773. let name = "";
  774. for (let i = 0; i < this.goodType.length; i++) {
  775. if (this.goodType[i].id == id) {
  776. name = this.goodType[i].type_name;
  777. }
  778. }
  779. return name;
  780. },
  781. GetAllGoodType: function() {
  782. GetAllGoodType().then(response => {
  783. if (response.data.state == 0) {
  784. this.$message.error(response.data.msg);
  785. return false;
  786. } else {
  787. for (let i = 0; i < response.data.data.goodType.length; i++) {
  788. this.goodType.push(response.data.data.goodType[i]);
  789. }
  790. }
  791. });
  792. },
  793. GetAllGoodInfo: function() {
  794. GetAllGoodInfo().then(response => {
  795. if (response.data.state == 0) {
  796. this.$message.error(response.data.msg);
  797. return false;
  798. } else {
  799. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  800. this.goodInfo.push(response.data.data.goodInfo[i]);
  801. }
  802. }
  803. });
  804. },
  805. clicks: function() {
  806. console.log(this.WarehouseInfo.warehouseInfoDate);
  807. },
  808. handleWarehouse: function() {
  809. this.$router.push({ path: "/stock/in/add", query: { type: this.type } });
  810. },
  811. handleReturnSales: function() {
  812. // this.$router.push({path:'/patients/create'}
  813. if (this.multipleSelection.length <= 0) {
  814. this.$message.error("请选择退货商品");
  815. return;
  816. }
  817. const ids = [];
  818. for (let i = 0; i < this.multipleSelection.length; i++) {
  819. ids.push(this.multipleSelection[i].id);
  820. }
  821. this.$router.push({ name: "salesReturn", query: { id: ids.join("&") } });
  822. },
  823. handleReturnSalesRecord: function() {
  824. this.$router.push({ name: "salesReutrnRecord" });
  825. },
  826. handleWarehouseRecord: function() {
  827. this.$router.push({ name: "warehouseRecord" });
  828. },
  829. handleSelectionChange: function(val) {
  830. this.multipleSelection = val;
  831. },
  832. handleSizeChange(val) {
  833. this.limit = val;
  834. this.GetWarehouse();
  835. },
  836. handleCurrentChange(val) {
  837. this.page = val;
  838. this.GetWarehouse();
  839. },
  840. startTimeChange(val) {
  841. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  842. if (time > 0) {
  843. this.$message.error("结束时间不能小于开始时间");
  844. this.start_time = "";
  845. } else {
  846. this.startTime = this.getTimestamp(val);
  847. this.GetWarehouse();
  848. }
  849. },
  850. endTimeChange(val) {
  851. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  852. if (time < 0) {
  853. this.$message.error("结束时间不能小于开始时间");
  854. this.end_time = "";
  855. } else {
  856. this.GetWarehouse();
  857. }
  858. },
  859. getTimestamp(time) {
  860. // 把时间日期转成时间戳
  861. return new Date(time).getTime() / 1000;
  862. },
  863. getTime(val, temp) {
  864. if (val != 0) {
  865. return uParseTime(val, temp);
  866. } else {
  867. return "";
  868. }
  869. },
  870. calculate: function(val) {
  871. return Math.round(parseFloat(val) * 100) / 100;
  872. },
  873. GetConfigInfo: function() {
  874. GetAllConfig().then(response => {
  875. if (response.data.state == 0) {
  876. this.$message.error(response.data.msg);
  877. return false;
  878. } else {
  879. this.manufacturer = response.data.data.manufacturer;
  880. this.dealer = response.data.data.dealer;
  881. this.manufacturer.splice(0, 0, { id: 0, manufacturer_name: "全部" });
  882. this.dealer.splice(0, 0, { id: 0, dealer_name: "全部" });
  883. }
  884. });
  885. },
  886. getManufactuerName: function(manufacturer_id) {
  887. for (let i = 0; i < this.manufacturer.length; i++) {
  888. if (this.manufacturer[i].id == manufacturer_id) {
  889. return this.manufacturer[i].manufacturer_name;
  890. }
  891. }
  892. },
  893. getDealerName: function(dealer_id) {
  894. for (let i = 0; i < this.dealer.length; i++) {
  895. if (this.dealer[i].id == dealer_id) {
  896. return this.dealer[i].dealer_name;
  897. }
  898. }
  899. },
  900. handleEdit: function(index, row) {
  901. this.$router.push({
  902. name: "stockInDetail",
  903. query: { id: row.id, type: this.type }
  904. });
  905. },
  906. handleDelete: function(index, row) {
  907. const ids = [];
  908. ids.push(row.id);
  909. const idStr = ids.join(",");
  910. const params = {
  911. ids: idStr
  912. };
  913. this.$confirm("确认删除入库单记录?", "删除入库单记录", {
  914. confirmButtonText: "确定",
  915. cancelButtonText: "取消",
  916. type: "warning"
  917. })
  918. .then(() => {
  919. deleteWarehouseInfo(params).then(response => {
  920. if (response.data.state == 0) {
  921. this.$message.error(response.data.msg);
  922. return false;
  923. } else {
  924. this.$notify({
  925. title: "成功",
  926. message: "删除成功",
  927. type: "success",
  928. duration: 2000
  929. });
  930. for (let i = 0; i < ids.length; i++) {
  931. for (let y = 0; y < this.Warehouse.warehouseDate.length; y++) {
  932. if (ids[i] == this.Warehouse.warehouseDate[y].id) {
  933. this.Warehouse.warehouseDate.splice(y, 1);
  934. }
  935. }
  936. }
  937. }
  938. });
  939. })
  940. .catch(() => {});
  941. },
  942. changeAllSelected: function(val) {
  943. if (val) {
  944. this.$refs.multipleTable.toggleAllSelection();
  945. } else {
  946. this.$refs.multipleTable.clearSelection();
  947. }
  948. },
  949. select(selection) {
  950. this.selectedTableData = selection;
  951. },
  952. batchDelete() {
  953. if (this.selectedTableData.length <= 0) {
  954. this.$message.error("请选择要删除的记录");
  955. return;
  956. }
  957. const ids = [];
  958. for (let i = 0; i < this.selectedTableData.length; i++) {
  959. ids.push(this.selectedTableData[i].id);
  960. }
  961. const idStr = ids.join(",");
  962. const params = {
  963. ids: idStr
  964. };
  965. this.$confirm("确认删除入库单记录?", "删除入库单记录", {
  966. confirmButtonText: "确定",
  967. cancelButtonText: "取消",
  968. type: "warning"
  969. })
  970. .then(() => {
  971. deleteWarehouseInfo(params).then(response => {
  972. if (response.data.state == 0) {
  973. this.$message.error(response.data.msg);
  974. return false;
  975. } else {
  976. this.$notify({
  977. title: "成功",
  978. message: "删除成功",
  979. type: "success",
  980. duration: 2000
  981. });
  982. for (let i = 0; i < ids.length; i++) {
  983. for (let y = 0; y < this.Warehouse.warehouseDate.length; y++) {
  984. if (ids[i] == this.Warehouse.warehouseDate[y].id) {
  985. this.Warehouse.warehouseDate.splice(y, 1);
  986. }
  987. }
  988. }
  989. }
  990. });
  991. })
  992. .catch(() => {});
  993. },
  994. handleSearch(id){
  995. this.GetOrderDetail(id)
  996. this.drug_id = id
  997. this.dialogVisible = true
  998. },
  999. GetOrderDetail: function(id) {
  1000. const params = {
  1001. id: id
  1002. };
  1003. getWarehouseInfoList(params).then(response => {
  1004. if (response.data.state == 0) {
  1005. this.$message.error(response.data.msg);
  1006. return false;
  1007. } else {
  1008. for (let i = 0; i < response.data.data.info.length; i++) {
  1009. this.WarehouseInfo.warehouseInfoDate.push(response.data.data.info[i]);
  1010. response.data.data.info[i].product_date = this.getTime(
  1011. response.data.data.info[i].product_date,
  1012. "{y}-{m}-{d}"
  1013. );
  1014. response.data.data.info[i].expiry_date = this.getTime(
  1015. response.data.data.info[i].expiry_date,
  1016. "{y}-{m}-{d}"
  1017. );
  1018. response.data.data.info[i].price = response.data.data.info[i].price.toString();
  1019. response.data.data.info[i].warehousing_count = response.data.data.info[i].warehousing_count.toString();
  1020. this.recordInfo.recordData.push(response.data.data.info[i]);
  1021. }
  1022. this.WarehouseInfo.warehouse = response.data.data.warehousing;
  1023. }
  1024. });
  1025. },
  1026. editRecord: function() {
  1027. this.editDialogVisible = true
  1028. },
  1029. deleteRecord: function() {
  1030. const ids = [];
  1031. ids.push(this.WarehouseInfo.warehouse.id);
  1032. const idStr = ids.join(",");
  1033. const params = {
  1034. ids: idStr
  1035. };
  1036. this.$confirm("确认删除入库单记录?", "删除入库单记录", {
  1037. confirmButtonText: "确定",
  1038. cancelButtonText: "取消",
  1039. type: "warning"
  1040. })
  1041. .then(() => {
  1042. deleteWarehouseInfo(params).then(response => {
  1043. if (response.data.state == 0) {
  1044. this.$message.error(response.data.msg);
  1045. return false;
  1046. } else {
  1047. this.$notify({
  1048. title: "成功",
  1049. message: "删除成功",
  1050. type: "success",
  1051. duration: 2000
  1052. });
  1053. this.$router.back(-1);
  1054. }
  1055. });
  1056. })
  1057. .catch(() => {});
  1058. },
  1059. typeName: function(good_type_id) {
  1060. let name = "";
  1061. for (let i = 0; i < this.goodType.length; i++) {
  1062. if (this.goodType[i].id == good_type_id) {
  1063. name = this.goodType[i].type_name;
  1064. }
  1065. }
  1066. return name;
  1067. },
  1068. showDialog(index, row) {
  1069. this.currentIndex = index;
  1070. const params = {
  1071. manufacturer_id: this.form.manufacturer,
  1072. dealer_id: this.form.dealer
  1073. };
  1074. this.propForm.goods = []
  1075. GetAllGoodInfoByID(params).then(response => {
  1076. if (response.data.state == 0) {
  1077. this.$message.error(response.data.msg);
  1078. return false;
  1079. } else {
  1080. if (response.data.data.goodInfo.length <= 0) {
  1081. this.$message.error("该厂商或经销商没有物品信息");
  1082. return;
  1083. }
  1084. this.$refs.dialog.show();
  1085. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  1086. this.propForm.goodType.push(
  1087. response.data.data.goodInfo[i].type
  1088. );
  1089. }
  1090. const obj = {};
  1091. this.propForm.goodType = this.propForm.goodType.reduce(
  1092. (cur, next) => {
  1093. obj[next.id] ? "" : (obj[next.id] = true && cur.push(next));
  1094. return cur;
  1095. },
  1096. []
  1097. ); // 设置cur默认类型为数组,并且初始值为空的数组
  1098. }
  1099. for (let i = 0; i < this.propForm.goodType.length; i++) {
  1100. let goodInfo = [];
  1101. let goodObj = {};
  1102. for (let a = 0; a < response.data.data.goodInfo.length; a++) {
  1103. var respObj = response.data.data.goodInfo[a];
  1104. respObj["isSelected"] = false;
  1105. if (respObj.type.id == this.propForm.goodType[i].id) {
  1106. goodInfo.push(respObj);
  1107. }
  1108. }
  1109. const obj = {};
  1110. goodInfo = goodInfo.reduce((cur, next) => {
  1111. obj[next.id] ? "" : (obj[next.id] = true && cur.push(next));
  1112. return cur;
  1113. }, []); // 设置cur默认类型为数组,并且初始值为空的数组
  1114. this.$set(goodObj, this.propForm.goodType[i].id, goodInfo);
  1115. this.propForm.goods.push(goodObj);
  1116. }
  1117. });
  1118. },
  1119. specificationName: function(drug_id) {
  1120. let name = "";
  1121. for (let i = 0; i < this.goodInfo.length; i++) {
  1122. if (this.goodInfo[i].id == drug_id) {
  1123. name = this.goodInfo[i].specification_name;
  1124. }
  1125. }
  1126. return name;
  1127. },
  1128. submit() {
  1129. this.$refs["tableForm"].validate(valid => {
  1130. if (valid) {
  1131. const array = this.recordInfo.recordData;
  1132. console.log('array',array)
  1133. for (let i = 0; i < array.length; i++) {
  1134. if (array[i].good_type_id == 0) {
  1135. this.$message.error("商品类型不能为空");
  1136. return;
  1137. }
  1138. if (array[i].good_id == 0) {
  1139. this.$message.error("规格名称不能为空");
  1140. return;
  1141. }
  1142. }
  1143. const params = {
  1144. stockIn: this.recordInfo.recordData
  1145. };
  1146. EditWarehouse(
  1147. params,
  1148. this.warehousing_time,
  1149. this.drug_id,
  1150. this.type,
  1151. this.form.manufacturer,
  1152. this.form.dealer
  1153. ).then(response => {
  1154. if (response.data.state == 0) {
  1155. this.$message.error(response.data.msg);
  1156. return false;
  1157. } else {
  1158. this.$message.success("入库成功");
  1159. this.dialogVisible = false
  1160. this.editDialogVisible = false
  1161. }
  1162. });
  1163. } else {
  1164. return false;
  1165. }
  1166. });
  1167. },
  1168. changeManufacturer(val) {
  1169. },
  1170. changeDealer(val) {
  1171. },
  1172. DeleteWarehouseInfoItem: function(index, row) {
  1173. if (row.id == 0) {
  1174. this.recordInfo.recordData.splice(index, 1);
  1175. } else {
  1176. const params = {
  1177. id: row.id
  1178. };
  1179. this.$confirm("确认删除该入库商品信息记录?", "删除入库商品信息记录", {
  1180. confirmButtonText: "确定",
  1181. cancelButtonText: "取消",
  1182. type: "warning"
  1183. })
  1184. .then(() => {
  1185. DeleteWarehouseInfoItem(params).then(response => {
  1186. if (response.data.state == 0) {
  1187. this.$message.error(response.data.msg);
  1188. return false;
  1189. } else {
  1190. this.$message.success("删除成功");
  1191. this.recordInfo.recordData.splice(index, 1);
  1192. }
  1193. });
  1194. })
  1195. .catch(() => {});
  1196. }
  1197. },
  1198. handleEditTwo: function(index, row) {
  1199. const tempObj = {};
  1200. tempObj["id"] = 0;
  1201. tempObj["good_type_id"] = 0;
  1202. tempObj["good_id"] = 0;
  1203. tempObj["number"] = "";
  1204. tempObj["product_date"] = "";
  1205. tempObj["expiry_date"] = "";
  1206. tempObj["warehousing_count"] = "";
  1207. tempObj["price"] = "";
  1208. tempObj["remark"] = "";
  1209. tempObj["dealer"] = "";
  1210. tempObj["manufacturer"] = "";
  1211. this.recordInfo.recordData.push(tempObj);
  1212. },
  1213. comfirm: function(val) {
  1214. this.$refs.dialog.hide();
  1215. this.propForm.goodType = [];
  1216. this.propForm.goods = [];
  1217. if (val.selectedGoodInfo.length > 0) {
  1218. for (let i = val.selectedGoodInfo.length - 1; ; i--) {
  1219. if (i == 0) {
  1220. this.recordInfo.recordData[this.currentIndex].good_type_id =
  1221. val.selectedGoodInfo[i].good_type_id;
  1222. this.recordInfo.recordData[this.currentIndex].good_id =
  1223. val.selectedGoodInfo[i].id;
  1224. this.recordInfo.recordData[
  1225. this.currentIndex
  1226. ].price = val.selectedGoodInfo[i].buy_price.toString();
  1227. } else {
  1228. const tempForm = {};
  1229. tempForm["id"] = 0;
  1230. tempForm["good_type_id"] = val.selectedGoodInfo[i].good_type_id;
  1231. tempForm["good_id"] = val.selectedGoodInfo[i].id;
  1232. tempForm["number"] = "";
  1233. tempForm["product_date"] = "";
  1234. tempForm["expiry_date"] = "";
  1235. tempForm["warehousing_count"] = "";
  1236. tempForm["price"] = val.selectedGoodInfo[i].buy_price.toString();
  1237. tempForm["remark"] = "";
  1238. tempForm["dealer"] = "";
  1239. tempForm["manufacturer"] = "";
  1240. this.recordInfo.recordData.splice(
  1241. this.currentIndex + 1,
  1242. 0,
  1243. tempForm
  1244. );
  1245. }
  1246. }
  1247. }
  1248. this.currentIndex = -1;
  1249. },
  1250. cancle: function() {
  1251. this.$refs.dialog.hide();
  1252. this.propForm.goods = [];
  1253. this.propForm.goodType = [];
  1254. },
  1255. }
  1256. };
  1257. </script>
  1258. <style rel="stylesheet/css" lang="scss" scoped>
  1259. .information {
  1260. border: 1px #dcdfe6 solid;
  1261. padding: 30px 20px 30px 20px;
  1262. .border {
  1263. border-bottom: 1px #dcdfe6 solid;
  1264. margin: 0px 0 20px 0;
  1265. }
  1266. }
  1267. .edit_separater {
  1268. border-top: 1px solid rgb(233, 233, 233);
  1269. margin-top: 15px;
  1270. margin-bottom: 15px;
  1271. }
  1272. </style>
  1273. <style>
  1274. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  1275. font-size: 12px;
  1276. }
  1277. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  1278. background: #6fb5fa;
  1279. }
  1280. .count {
  1281. color: #bd2c00;
  1282. }
  1283. .el-table td,
  1284. .el-table th.is-leaf,
  1285. .el-table--border,
  1286. .el-table--group {
  1287. border-color: #d0d3da;
  1288. }
  1289. .el-table--border::after,
  1290. .el-table--group::after,
  1291. .el-table::before {
  1292. background-color: #d0d3da;
  1293. }
  1294. </style>