drugStockOutOrderEdit.vue 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb v-if="this.$route.query.type == 1" :crumbs='crumbs'></bread-crumb>
  5. <bread-crumb v-if="this.$route.query.type == 2" :crumbs='crumbs2'></bread-crumb>
  6. <div style="float:right;">
  7. <el-button size="small" @click="back()" class="filter-item">取 消</el-button>
  8. <el-button size="small" type="primary" @click="submit()" class="filter-item">保 存</el-button>
  9. </div>
  10. </div>
  11. <div class="app-container">
  12. <!--<stock-in-dialog-->
  13. <!--ref="dialog"-->
  14. <!--:propForm="propForm"-->
  15. <!--:visibility="isVisibility"-->
  16. <!--v-on:dialog-comfirm="comfirm"-->
  17. <!--v-on:dialog-cancle="cancle"-->
  18. <!--&gt;</stock-in-dialog>-->
  19. <!--<stock-in-dialog-->
  20. <!--ref="dialog"-->
  21. <!--:propForm="propForm"-->
  22. <!--:visibility="isVisibility"-->
  23. <!--v-on:dialog-comfirm="comfirm"-->
  24. <!--v-on:dialog-cancle="cancle"-->
  25. <!--&gt;-->
  26. <!--</stock-in-dialog>-->
  27. <drugs-stock-dialog
  28. ref="dialog"
  29. :propForm="propForm"
  30. :visibility="isVisibility"
  31. v-on:dialog-comfirm="comfirm"
  32. v-on:dialog-cancle="cancle"
  33. >
  34. </drugs-stock-dialog>
  35. <div class="cell clearfix">
  36. <label class="title"><span class="name">出库时间</span> : </label>
  37. <el-date-picker size="small" v-model="warehouse_out_time" prefix-icon="el-icon-date" :editable="false"
  38. style="width: 196px;"
  39. type="date" placeholder="选择日期时间" align="right" format="yyyy-MM-dd"
  40. value-format="yyyy-MM-dd"></el-date-picker>
  41. </div>
  42. <div class="cell clearfix">
  43. <label class="title"><span class="name">经销商</span> : </label>
  44. <el-select size="small" v-model="form.dealer" clearable placeholder="请选择经销商" @change="changeDealer">
  45. <el-option
  46. v-for="(option, index) in dealer"
  47. :key="index"
  48. :label="option.dealer_name"
  49. :value="option.id">
  50. </el-option>
  51. </el-select>
  52. </div>
  53. <div class="cell clearfix">
  54. <label class="title"><span class="name">厂商</span> : </label>
  55. <el-select size="small" v-model="form.manufacturer" clearable placeholder="请选择厂商" @change="changeManufacturer">
  56. <el-option
  57. v-for="(option, index) in manufacturer"
  58. :key="index"
  59. :label="option.manufacturer_name"
  60. :value="option.id">
  61. </el-option>
  62. </el-select>
  63. </div>
  64. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  65. <el-table :data="recordInfo.recordData" :class="signAndWeighBoxPatients" style="width: 100%" border
  66. max-height="450" :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  67. >
  68. <el-table-column align="center" width="200">
  69. <template slot="header" slot-scope="scope">
  70. <span>药品名称<span style="color: red">*</span></span>
  71. </template>
  72. <template slot-scope="scope">
  73. <el-form-item style="padding-top: 15px">
  74. <el-input
  75. placeholder="请输入药品名称"
  76. v-model="scope.row.drug_id"
  77. :value="typeName(scope.row.drug_id)"
  78. @focus="showDialog(scope.$index, scope.row)"
  79. ></el-input>
  80. </el-form-item>
  81. </template>
  82. </el-table-column>
  83. <el-table-column align="center" width="200">
  84. <template slot="header" slot-scope="scope">
  85. <span>规格名称<span style="color: red">*</span></span>
  86. </template>
  87. <template slot-scope="scope">
  88. <el-form-item style="padding-top: 15px">
  89. <el-input
  90. placeholder="请输入规格名称"
  91. v-model="scope.row.drug_id"
  92. :value="specificationName(scope.row.drug_id)"
  93. @focus="showDialog(scope.$index, scope.row)"
  94. ></el-input>
  95. </el-form-item>
  96. </template>
  97. </el-table-column>
  98. <el-table-column min-width="23" align="center">
  99. <template slot="header" slot-scope="scope">
  100. <span>单价<span style="color: red">*</span></span>
  101. </template>
  102. <template slot-scope="scope">
  103. <!--<el-input type="number" v-model="scope.row.price" @blur="handleBlur(scope.$index, scope.row)"></el-input>-->
  104. <el-form-item :prop="'recordData.' + scope.$index + '.price'" :rules='tableRules.price'
  105. style="padding-top: 17px">
  106. <el-input type="number" v-model="scope.row.price"></el-input>
  107. </el-form-item>
  108. </template>
  109. </el-table-column>
  110. <el-table-column min-width="23" align="center">
  111. <template slot="header" slot-scope="scope">
  112. <span>出库数量<span style="color: red">*</span></span>
  113. </template>
  114. <template slot-scope="scope">
  115. <el-form-item :prop="'recordData.' + scope.$index + '.count'" :rules='tableRules.count'
  116. style="padding-top: 17px">
  117. <el-input type="number" v-model="scope.row.count"></el-input>
  118. </el-form-item>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="总价" min-width="20" align="center">
  122. <template slot-scope="scope">
  123. {{calculate(scope.row.price*scope.row.count)}}
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="备注" min-width="20" align="center">
  127. <template slot-scope="scope">
  128. <el-input v-model="scope.row.remark"></el-input>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="操作" align="center" min-width="20">
  132. <template slot-scope="scope">
  133. <el-tooltip class="item" effect="dark" content="新增" placement="top">
  134. <el-button
  135. size="mini"
  136. type="primary"
  137. icon="el-icon-circle-plus-outline"
  138. @click="handleEdit(scope.$index, scope.row)">
  139. </el-button>
  140. </el-tooltip>
  141. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  142. <el-button
  143. size="mini"
  144. type="danger"
  145. icon="el-icon-delete"
  146. @click="handleDelete(scope.$index, scope.row)">
  147. </el-button>
  148. </el-tooltip>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. </el-form>
  153. </div>
  154. </div>
  155. </template>
  156. <script>
  157. import { uParseTime } from '@/utils/tools'
  158. import { deleteDrugWarehouseOutInfo, editDrugWarehouseoutInfo, getDrugSalesReturnConfig, getDrugWarehouseOutInfo,GetAllConfig,GetAllDrugInfoByID } from '@/api/drug/drug_stock'
  159. import BreadCrumb from '../../components/bread-crumb'
  160. import DrugsStockDialog from './drugsStockDialog/index'
  161. export default {
  162. components: { DrugsStockDialog, BreadCrumb},
  163. name: 'salesReturnEdit',
  164. data() {
  165. return {
  166. crumbs: [
  167. { path: false, name: '库存管理' },
  168. { path: false, name: '耗材出库单' },
  169. { path: false, name: '编辑出库单' }
  170. ],
  171. crumbs2: [
  172. { path: false, name: '库存管理' },
  173. { path: false, name: '其他出库单' },
  174. { path: false, name: '编辑出库单' }
  175. ],
  176. signAndWeighBoxPatients: 'sign-and-weigh-box-patients',
  177. adminUserOptions: null,
  178. currentIndex: 0,
  179. warehouse_out_time: '',
  180. recordInfo: {
  181. recordData: [],
  182. stock_in_code: '',
  183. current_index: ''
  184. },
  185. tableRules: {
  186. count: [
  187. { required: true, message: '数量不能为空', trigge: 'blur' }
  188. ],
  189. price: [
  190. { required: true, message: '单价不能为空', trigger: 'blur' }
  191. ]
  192. },
  193. ruleForm: {
  194. manufacturer: [
  195. { required: true, message: '请选择厂商', trigger: 'change' }
  196. ]
  197. },
  198. // prop
  199. isVisibility: false,
  200. propForm: {
  201. goods:[],
  202. goodType: [],
  203. goodInfo: [],
  204. goodUnit: [],
  205. title: '入库',
  206. manufacturer: 0,
  207. dealer: 0
  208. },
  209. form: {
  210. manufacturer: 0,
  211. dealer: 0
  212. },
  213. warehouseInfoList: [],
  214. warehouseOut: {},
  215. manufacturer: [],
  216. dealer: [],
  217. goodType: [],
  218. goodInfo:[],
  219. }
  220. },
  221. methods: {
  222. comfirm: function(val) {
  223. this.$refs.dialog.hide();
  224. this.propForm.goodType = [];
  225. this.propForm.goods = [];
  226. if (val.selectedGoodInfo.length > 0) {
  227. for (let i = val.selectedGoodInfo.length - 1; ; i--) {
  228. if (i == 0) {
  229. this.recordInfo.recordData[this.currentIndex].drug_id =
  230. val.selectedGoodInfo[i].id;
  231. } else {
  232. const tempForm = {};
  233. tempForm["id"] = 0;
  234. tempForm["drug_id"] = val.selectedGoodInfo[i].id;
  235. tempForm["count"] = "";
  236. tempForm["price"] = val.selectedGoodInfo[i].buy_price.toString();
  237. tempForm["remark"] = "";
  238. this.recordInfo.recordData.splice(
  239. this.currentIndex + 1,
  240. 0,
  241. tempForm
  242. );
  243. }
  244. }
  245. }
  246. this.currentIndex = -1;
  247. },
  248. cancle: function() {
  249. this.$refs.dialog.hide()
  250. this.propForm.goods = [];
  251. this.propForm.goodType = [];
  252. }, GetConfigInfo: function() {
  253. const loading = this.$loading({
  254. lock: true,
  255. text: "Loading",
  256. spinner: "el-icon-loading",
  257. background: "rgba(0, 0, 0, 0.7)"
  258. });
  259. GetAllConfig().then(response => {
  260. if (response.data.state == 0) {
  261. this.$message.error(response.data.msg);
  262. return false;
  263. } else {
  264. this.manufacturer = response.data.data.manufacturer;
  265. this.dealer = response.data.data.dealer;
  266. for(let i = 0; i< response.data.data.drugs.length;i++){
  267. this.goodType.push(response.data.data.drugs[i])
  268. if(response.data.data.drugs[i].drug_specs != null) {
  269. for (let b = 0; b < response.data.data.drugs[i].drug_specs.length; b++) {
  270. this.goodInfo.push(response.data.data.drugs[i].drug_specs[b])
  271. }
  272. }
  273. }
  274. this.manufacturer.splice(0, 0, { id: 0, manufacturer_name: "全部" });
  275. this.dealer.splice(0, 0, { id: 0, dealer_name: "全部" });
  276. }
  277. loading.close();
  278. });
  279. }, typeName: function(drug_id) {
  280. let name = "";
  281. for (let i = 0; i < this.goodInfo.length; i++) {
  282. if (this.goodInfo[i].id == drug_id) {
  283. name = this.goodInfo[i].drug_name;
  284. }
  285. }
  286. return name;
  287. },
  288. specificationName: function(drug_id) {
  289. console.log(this.goodInfo)
  290. let name = "";
  291. for (let i = 0; i < this.goodInfo.length; i++) {
  292. if (this.goodInfo[i].id == drug_id) {
  293. name = this.goodInfo[i].drug_spec;
  294. }
  295. }
  296. return name;
  297. }, handleEdit: function(index, row) {
  298. const tempObj = {}
  299. tempObj['id'] = 0
  300. tempObj['drug_id'] = 0
  301. tempObj['count'] = ''
  302. tempObj['price'] = ''
  303. tempObj['remark'] = ''
  304. this.recordInfo.recordData.push(tempObj)
  305. }, handleDelete: function(index, row) {
  306. if (row.id == 0) {
  307. this.recordInfo.recordData.splice(index, 1)
  308. } else {
  309. const params = {
  310. id: row.id
  311. }
  312. this.$confirm('确认删除该出库商品信息记录?', '删除出库商品信息记录', {
  313. confirmButtonText: '确定',
  314. cancelButtonText: '取消',
  315. type: 'warning'
  316. }).then(() => {
  317. deleteDrugWarehouseOutInfo(params).then(response => {
  318. if (response.data.state == 0) {
  319. this.$message.error(response.data.msg)
  320. return false
  321. } else {
  322. this.$message.success('删除成功')
  323. this.recordInfo.recordData.splice(index, 1)
  324. }
  325. })
  326. }).catch(() => {
  327. })
  328. }
  329. }, getTime(val, temp) {
  330. if (val != 0) {
  331. return uParseTime(val, temp)
  332. } else {
  333. return ''
  334. }
  335. },
  336. showDialog(index, row) {
  337. this.currentIndex = index;
  338. const loading = this.$loading({
  339. lock: true,
  340. text: "Loading",
  341. spinner: "el-icon-loading",
  342. background: "rgba(0, 0, 0, 0.7)"
  343. });
  344. const params = {
  345. manufacturer_id: this.form.manufacturer,
  346. dealer_id: this.form.dealer
  347. };
  348. GetAllDrugInfoByID(params).then(response => {
  349. if (response.data.state == 0) {
  350. this.$message.error(response.data.msg);
  351. return false;
  352. } else {
  353. if (response.data.data.goodInfo.length <= 0) {
  354. this.$message.error("该厂商或经销商没有药品信息");
  355. return;
  356. }
  357. this.$refs.dialog.show();
  358. for (let i = 0; i < response.data.data.drugs.length; i++) {
  359. this.propForm.goods.push(
  360. response.data.data.drugs[i]
  361. );
  362. }
  363. const obj = {};
  364. this.propForm.goods = this.propForm.goods.reduce(
  365. (cur, next) => {
  366. obj[next.id] ? "" : (obj[next.id] = true && cur.push(next));
  367. return cur;
  368. },
  369. []
  370. ); // 设置cur默认类型为数组,并且初始值为空的数组
  371. }
  372. for (let i = 0; i < this.propForm.goods.length; i++) {
  373. for (let a = 0; a < this.propForm.goods[i].drug_specs.length; a++) {
  374. var respObj = this.propForm.goods[i].drug_specs[a];
  375. respObj["isSelected"] = false;
  376. }
  377. }
  378. loading.close();
  379. });
  380. },
  381. back() {
  382. this.$router.go(-1)
  383. }, submit() {
  384. this.$refs['tableForm'].validate((valid) => {
  385. if (valid) {
  386. const array = this.recordInfo.recordData
  387. for (let i = 0; i < array.length; i++) {
  388. if (array[i].drug_id == 0) {
  389. this.$message.error("药品名称或者药品规格名称不能为空");
  390. return;
  391. }
  392. }
  393. const params = {
  394. 'stockOut': this.recordInfo.recordData
  395. }
  396. editDrugWarehouseoutInfo(params, this.warehouse_out_time, this.$route.query.id, this.$route.query.type, this.form.manufacturer, this.form.dealer).then(response => {
  397. if (response.data.state == 0) {
  398. this.$message.error(response.data.msg)
  399. return false
  400. } else {
  401. this.$message.success('保存成功')
  402. this.$router.back(-1)
  403. }
  404. })
  405. } else {
  406. return false
  407. }
  408. })
  409. }, GetOrderDetail: function(order_id) {
  410. const params = {
  411. 'id': order_id
  412. }
  413. getDrugWarehouseOutInfo(params).then(response => {
  414. if (response.data.state == 0) {
  415. this.$message.error(response.data.msg)
  416. return false
  417. } else {
  418. for (let i = 0; i < response.data.data.list.length; i++) {
  419. response.data.data.list[i].price = response.data.data.list[i].price.toString()
  420. response.data.data.list[i].count = response.data.data.list[i].count.toString()
  421. this.recordInfo.recordData.push(response.data.data.list[i])
  422. }
  423. this.warehouseOut = response.data.data.info
  424. this.warehouse_out_time = this.getTime(this.warehouseOut.warehouse_out_time, '{y}-{m}-{d}')
  425. this.form.manufacturer = this.warehouseOut.manufacturer
  426. this.form.dealer = this.warehouseOut.dealer
  427. }
  428. if (this.recordInfo.recordData.length == 0) {
  429. const tempObj = {}
  430. tempObj['id'] = 0
  431. tempObj['drug_id'] = 0
  432. tempObj['count'] = ''
  433. tempObj['price'] = ''
  434. tempObj['remark'] = ''
  435. this.recordInfo.recordData.push(tempObj)
  436. }
  437. })
  438. }, calculate: function(val) {
  439. if (val == 0) {
  440. return ''
  441. }
  442. return Math.round(parseFloat(val) * 100) / 100
  443. }, changeManufacturer(val) {
  444. this.propForm.manufacturer = val
  445. }, changeDealer(val) {
  446. this.propForm.dealer = val
  447. }
  448. },
  449. created() {
  450. this.GetConfigInfo()
  451. this.propForm.goodUnit = this.$store.getters.good_unit
  452. const order_id = this.$route.query.id
  453. this.GetOrderDetail(order_id)
  454. }
  455. }
  456. </script>
  457. <style rel="stylesheet/css" lang="scss" scoped>
  458. .information {
  459. border: 1px #dcdfe6 solid;
  460. padding: 30px 20px 30px 20px;
  461. .border {
  462. border-bottom: 1px #dcdfe6 solid;
  463. margin: 0px 0 20px 0;
  464. }
  465. }
  466. .edit_separater {
  467. border-top: 1px solid rgb(233, 233, 233);
  468. margin-top: 15px;
  469. margin-bottom: 15px;
  470. }
  471. </style>
  472. <style>
  473. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  474. font-size: 12px;
  475. }
  476. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  477. background: #6fb5fa;
  478. }
  479. </style>