stockInOrderAdd.vue 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb v-if="type == 1" :crumbs='crumbs'></bread-crumb>
  5. <bread-crumb v-if="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" v-loading="loading">
  12. <stock-in-dialog ref="dialog" :propForm="propForm"
  13. :visibility="isVisibility"
  14. v-on:dialog-comfirm="comfirm"
  15. v-on:dialog-cancle="cancle">
  16. </stock-in-dialog>
  17. <div class="cell clearfix">
  18. <label class="title"><span class="name">入库时间</span> : </label>
  19. <el-date-picker size="small" v-model="warehousing_time" prefix-icon="el-icon-date" :editable="false"
  20. style="width: 196px;" type="date" placeholder="选择日期时间" align="right" format="yyyy-MM-dd"
  21. value-format="yyyy-MM-dd"></el-date-picker>
  22. </div>
  23. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  24. <el-table id="oictable" :data="recordInfo.recordData" :class="signAndWeighBoxPatients" border
  25. style="width: 100%"
  26. max-height="450" :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  27. >
  28. <el-table-column align="center" width="200" fixed="left">
  29. <template slot="header" slot-scope="scope">
  30. <span>耗材名称</span>
  31. </template>
  32. <template slot-scope="scope">
  33. <el-autocomplete
  34. class="checkSearch"
  35. popper-class="my-autocomplete"
  36. v-model="scope.row.good_name"
  37. :fetch-suggestions="querySearchAsync"
  38. :trigger-on-focus="true"
  39. placeholder="请输入耗材名称"
  40. @select="handleSelect"
  41. @input="changeGoodName(scope.$index)"
  42. style="width:160px;"
  43. >
  44. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  45. <template slot-scope="{ item }">
  46. <div class="name">{{ item.good_name +" " +item.specification_name + " "+item.manufacturer }}</div>
  47. </template>
  48. </el-autocomplete>
  49. </template>
  50. </el-table-column>
  51. <el-table-column align="center" width="140">
  52. <template slot="header" slot-scope="scope">
  53. <span>耗材类型<span style="color: red">*</span></span>
  54. </template>
  55. <template slot-scope="scope">
  56. <el-form-item style="padding-top: 20px;">
  57. <el-input placeholder="请输入耗材类型" v-model="scope.row.good_type_id" :value="typeName(scope.row.good_type_id)"></el-input>
  58. </el-form-item>
  59. </template>
  60. </el-table-column>
  61. <el-table-column align="center" width="140">
  62. <template slot="header" slot-scope="scope">
  63. <span>规格&单位<span style="color: red">*</span></span>
  64. </template>
  65. <template slot-scope="scope">
  66. <el-form-item style="padding-top: 20px">
  67. <el-input placeholder="请输入规格名称" v-model="scope.row.name"></el-input>
  68. </el-form-item>
  69. </template>
  70. </el-table-column>
  71. <el-table-column align="center" width="150">
  72. <template slot="header" slot-scope="scope">
  73. <span>批号<span style="color: red">*</span></span>
  74. </template>
  75. <template slot-scope="scope">
  76. <el-form-item style="padding-top: 20px" :prop="'recordData.' + scope.$index + '.number'"
  77. :rules='tableRules.number' >
  78. <el-input placeholder="请输入批号" v-model="scope.row.number"></el-input>
  79. </el-form-item>
  80. </template>
  81. </el-table-column>
  82. <el-table-column align="center" width="120">
  83. <template slot="header" slot-scope="scope">
  84. <span>入库数量<span style="color: red">*</span></span>
  85. </template>
  86. <template slot-scope="scope">
  87. <el-form-item :prop="'recordData.' + scope.$index + '.warehousing_count'"
  88. :rules='tableRules.warehousing_count' style="padding-top: 20px">
  89. <el-input placeholder="请输入入库数量" type="number" v-model="scope.row.warehousing_count" oninput="value=value.replace(/\D|^0/g,'')"></el-input>
  90. {{scope.row.min_unit}}
  91. </el-form-item>
  92. </template>
  93. </el-table-column>
  94. <el-table-column align="center" width="120">
  95. <template slot="header" slot-scope="scope">
  96. <span>零售价<span style="color: red">*</span></span>
  97. </template>
  98. <template slot-scope="scope">
  99. <el-form-item :prop="'recordData.' + scope.$index + '.packing_price'" :rules='tableRules.packing_price'
  100. style="padding-top: 20px">
  101. <el-input placeholder="请输入单价" type="number" v-model="scope.row.packing_price"></el-input>
  102. </el-form-item>
  103. </template>
  104. </el-table-column>
  105. <el-table-column align="center" width="120">
  106. <template slot="header" slot-scope="scope">
  107. <span>进货单价<span style="color: red">*</span></span>
  108. </template>
  109. <template slot-scope="scope">
  110. <el-form-item :prop="'recordData.' + scope.$index + '.price'" :rules='tableRules.price'
  111. style="padding-top: 20px">
  112. <el-input placeholder="请输入单价" type="number" v-model="scope.row.price"></el-input>
  113. </el-form-item>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="总价" align="center" width="80">
  117. <template slot-scope="scope">
  118. {{calculate(scope.row.price*scope.row.warehousing_count)}}
  119. </template>
  120. </el-table-column>
  121. <el-table-column align="center" width="180">
  122. <template slot="header" slot-scope="scope">
  123. <span>有效日期<span style="color: red">*</span></span>
  124. </template>
  125. <template slot-scope="scope">
  126. <el-form-item :prop="'recordData.' + scope.$index + '.expiry_date'"
  127. :rules="tableRules.expiry_date">
  128. <el-date-picker prefix-icon="el-icon-date" style="width: 145px" v-model="scope.row.expiry_date"
  129. type="date" placeholder="选择日期时间" format="yyyy-MM-dd"
  130. value-format="yyyy-MM-dd">
  131. </el-date-picker>
  132. </el-form-item>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="生产日期" align="center" width="180">
  136. <template slot-scope="scope">
  137. <el-date-picker prefix-icon="el-icon-date" v-model="scope.row.product_date" style="width: 145px"
  138. type="date" placeholder="选择日期时间" format="yyyy-MM-dd"
  139. value-format="yyyy-MM-dd">
  140. </el-date-picker>
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="生产厂家" align="center" width="150">
  144. <template slot-scope="scope">
  145. <el-select size="small" v-model="scope.row.manufacturer" filterable placeholder="请选择厂商">
  146. <el-option
  147. v-for="(option, index) in manufacturerList"
  148. :key="index"
  149. :label="option.manufacturer_name"
  150. :value="option.id">
  151. </el-option>
  152. </el-select>
  153. </template>
  154. </el-table-column>
  155. <el-table-column align="center" width="150">
  156. <template slot="header" slot-scope="scope">
  157. <span>批准文号</span>
  158. </template>
  159. <template slot-scope="scope">
  160. <el-form-item style="padding-top: 20px">
  161. <el-input placeholder="请输入批准文号" v-model="scope.row.license_number" ></el-input>
  162. </el-form-item>
  163. </template>
  164. </el-table-column>
  165. <el-table-column label="经销商" align="center" width="150">
  166. <template slot-scope="scope">
  167. <el-select size="small" v-model="scope.row.dealer" filterable placeholder="请选择厂商">
  168. <el-option
  169. v-for="(option, index) in dealerList"
  170. :key="index"
  171. :label="option.dealer_name"
  172. :value="option.id">
  173. </el-option>
  174. </el-select>
  175. </template>
  176. </el-table-column>
  177. <el-table-column label="备注" align="center" width="150">
  178. <template slot-scope="scope">
  179. <el-input placeholder="请输入备注" v-model="scope.row.remark"></el-input>
  180. </template>
  181. </el-table-column>
  182. <el-table-column label="操作" align="center" fixed="right" width="150">
  183. <template slot-scope="scope">
  184. <el-tooltip class="item" effect="dark" content="新增" placement="top">
  185. <el-button
  186. size="mini"
  187. type="primary"
  188. icon="el-icon-circle-plus-outline"
  189. @click="handleEdit(scope.$index, scope.row)">
  190. </el-button>
  191. </el-tooltip>
  192. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  193. <el-button
  194. size="mini"
  195. type="danger"
  196. icon="el-icon-delete"
  197. @click="handleDelete(scope.$index, scope.row)">
  198. </el-button>
  199. </el-tooltip>
  200. </template>
  201. </el-table-column>
  202. </el-table>
  203. </el-form>
  204. </div>
  205. </div>
  206. </template>
  207. <script>
  208. import stockInDialog from './Dialog/stockInDialog'
  209. import { uParseTime } from '@/utils/tools'
  210. import {getDataConfig } from "@/utils/data";
  211. import {
  212. deleteWarehouseInfo,
  213. GetAllConfig,
  214. GetAllGoodInfo,
  215. GetAllGoodInfoByID,
  216. GetAllGoodType,
  217. getWarehouseInfoByOrdeNumber,
  218. modifyWarehouseInfo,
  219. postWarehouse,
  220. postSearchGoodList
  221. } from '@/api/stock'
  222. import BreadCrumb from '../components/bread-crumb'
  223. export default {
  224. components: { BreadCrumb, stockInDialog },
  225. name: 'stockIn',
  226. data() {
  227. var checkGoodId = (rule, value, callback) => {
  228. setTimeout(() => {
  229. if (value == '' || value == 0) {
  230. return callback(new Error('规格名称不能为空'))
  231. }
  232. }, 2000)
  233. }
  234. return {
  235. crumbs: [
  236. { path: false, name: '库存管理' },
  237. { path: false, name: '耗材入库单' },
  238. { path: false, name: '新增入库单' }
  239. ],
  240. crumbs2: [
  241. { path: false, name: '库存管理' },
  242. { path: false, name: '其他入库单' },
  243. { path: false, name: '新增入库单' }
  244. ],
  245. signAndWeighBoxPatients: 'sign-and-weigh-box-patients',
  246. warehousing_time: '',
  247. adminUserOptions: null,
  248. currentIndex: 0,
  249. recordInfo: {
  250. recordData: [],
  251. stock_in_code: '',
  252. current_index: ''
  253. },
  254. tableRules: {
  255. price: [
  256. { required: true, message: '单价不能为空', trigger: 'blur' }
  257. ],
  258. packing_price: [
  259. { required: true, message: '零售价不能为空', trigger: 'blur' }
  260. ],
  261. warehousing_count: [
  262. { required: true, message: '数量不能为空', trigge: 'blur' }
  263. ],
  264. good_id: [
  265. { validator: checkGoodId, trigger: 'blur' }
  266. ],
  267. number:[
  268. { required: true, message: '批号不能为空', trigge: 'blur' }
  269. ],
  270. expiry_date:[
  271. { required: true, message: '有效日期不能为空', trigge: 'blur' }
  272. ],
  273. },
  274. type: this.$route.query.type,
  275. total: '',
  276. product_date: '',
  277. expiry_date: '',
  278. numbers: '',
  279. // prop
  280. isVisibility: false,
  281. propForm: {
  282. goods: [],
  283. goodType: [],
  284. goodInfo: [],
  285. goodUnit: [],
  286. title: '入库',
  287. formValue: {
  288. good_type_id: '',
  289. good_id: '',
  290. number: '',
  291. product_date: '',
  292. expiry_date: '',
  293. warehousing_count: '',
  294. price: '',
  295. remark: '',
  296. dealer: '',
  297. manufacturer: ''
  298. },
  299. isCreated: 1
  300. },
  301. goodInfo: {
  302. loading: false,
  303. goodTypeData: [],
  304. type_code: ''
  305. },
  306. form: {
  307. manufacturer: '',
  308. dealer: ''
  309. },
  310. formValue: {
  311. good_type_id: '',
  312. good_id: '',
  313. number: '',
  314. product_date: '',
  315. expiry_date: '',
  316. warehousing_count: '',
  317. price: '',
  318. remark: '',
  319. dealer: '',
  320. manufacturer: ''
  321. },
  322. manufacturer: [],
  323. dealerList: [],
  324. goodType: [],
  325. manufacturerList:[],
  326. goodList:[],
  327. loading:false,
  328. }
  329. },
  330. methods: {
  331. handleSave: function() {
  332. if (this.recordInfo.recordData.length <= 0) {
  333. this.$message.error('请添加入库信息')
  334. return
  335. }
  336. sessionStorage.removeItem('warehousing_orders')
  337. this.$router.back(-1)
  338. }, handleCancle: function() {
  339. this.$confirm('是否放弃编辑返回上一页?', '放弃编辑', {
  340. confirmButtonText: '确定',
  341. cancelButtonText: '取消',
  342. type: 'warning'
  343. }).then(() => {
  344. sessionStorage.removeItem('warehousing_orders')
  345. this.$router.back(-1)
  346. }).catch(() => {
  347. })
  348. }, handleCreate: function() {
  349. this.propForm.formValue = {}
  350. this.propForm.isCreated = 1
  351. this.isVisibility = true
  352. },
  353. comfirm: function(val) {
  354. this.propForm.goodType = []
  355. this.propForm.goods = []
  356. this.$refs.dialog.hide()
  357. console.log(val)
  358. if (val.selectedGoodInfo.length > 0) {
  359. for (let i = val.selectedGoodInfo.length - 1; i >= 0; i--) {
  360. if (i == 0) {
  361. this.recordInfo.recordData[this.currentIndex].good_type_id = val.selectedGoodInfo[i].good_type_id
  362. this.recordInfo.recordData[this.currentIndex].good_id = val.selectedGoodInfo[i].id
  363. this.recordInfo.recordData[this.currentIndex].price = val.selectedGoodInfo[i].buy_price.toString()
  364. this.recordInfo.recordData[this.currentIndex].good_unit = val.selectedGoodInfo[i].good_unit
  365. this.recordInfo.recordData[this.currentIndex].good_name = val.selectedGoodInfo[i].good_name
  366. } else {
  367. const tempForm = {}
  368. tempForm['good_type_id'] =val.selectedGoodInfo[i].good_type_id
  369. tempForm['good_id'] = val.selectedGoodInfo[i].id
  370. tempForm['number'] = ''
  371. tempForm['product_date'] = ''
  372. tempForm['expiry_date'] = ''
  373. tempForm['warehousing_count'] = ''
  374. tempForm['price'] = val.selectedGoodInfo[i].buy_price.toString()
  375. tempForm['remark'] = ''
  376. tempForm['dealer'] = ''
  377. tempForm['manufacturer'] = ''
  378. tempForm['good_unit'] = val.selectedGoodInfo[i].good_unit
  379. tempForm['good_name'] = val.selectedGoodInfo[i].good_name
  380. this.recordInfo.recordData.splice(this.currentIndex + 1, 0, tempForm)
  381. }
  382. }
  383. }
  384. this.currentIndex = -1
  385. }, cancle: function() {
  386. this.propForm.goodType = []
  387. this.propForm.goods = []
  388. this.$refs.dialog.hide()
  389. },
  390. GetAllGoodType: function() {
  391. GetAllGoodType().then(response => {
  392. if (response.data.state == 0) {
  393. this.$message.error(response.data.msg)
  394. return false
  395. } else {
  396. for (let i = 0; i < response.data.data.goodType.length; i++) {
  397. this.propForm.goodType.push(response.data.data.goodType[i])
  398. }
  399. }
  400. })
  401. },
  402. GetAllGoodInfo: function() {
  403. GetAllGoodInfo().then(response => {
  404. if (response.data.state == 0) {
  405. this.$message.error(response.data.msg)
  406. return false
  407. } else {
  408. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  409. this.propForm.goodInfo.push(response.data.data.goodInfo[i])
  410. }
  411. }
  412. })
  413. }, GetConfigInfo: function() {
  414. const loading = this.$loading({
  415. lock: true,
  416. text: 'Loading',
  417. spinner: 'el-icon-loading',
  418. background: 'rgba(0, 0, 0, 0.7)'
  419. })
  420. GetAllConfig().then(response => {
  421. if (response.data.state == 0) {
  422. this.$message.error(response.data.msg)
  423. return false
  424. } else {
  425. this.manufacturer = response.data.data.manufacturer
  426. this.dealer = response.data.data.dealer
  427. this.goodType = response.data.data.goodType
  428. this.goodInfo = response.data.data.goodInfo
  429. this.manufacturer.splice(0, 0, { id: 0, manufacturer_name: '全部' })
  430. this.dealer.splice(0, 0, { id: 0, dealer_name: '全部' })
  431. this.manufacturer.splice(0, 0, { id: -1, manufacturer_name: '其他' })
  432. this.dealer.splice(0, 0, { id: -1, dealer_name: '其他' })
  433. this.form.manufacturer = 0
  434. this.form.dealer = 0
  435. }
  436. loading.close()
  437. })
  438. }, typeName: function(good_type_id) {
  439. let name = ''
  440. for (let i = 0; i < this.goodType.length; i++) {
  441. if (this.goodType[i].id == good_type_id) {
  442. name = this.goodType[i].type_name
  443. }
  444. }
  445. return name
  446. }, specificationName: function(good_info_id) {
  447. let name = ''
  448. for (let i = 0; i < this.goodInfo.length; i++) {
  449. if (this.goodInfo[i].id == good_info_id) {
  450. name = this.goodInfo[i].specification_name
  451. }
  452. }
  453. return name
  454. },
  455. handleEdit: function(index, row) {
  456. const tempObj = {}
  457. tempObj['good_type_id'] = 0
  458. tempObj['good_id'] = 0
  459. tempObj['number'] = ''
  460. tempObj['product_date'] = ''
  461. tempObj['expiry_date'] = ''
  462. tempObj['warehousing_count'] = ''
  463. tempObj['price'] = ''
  464. tempObj['remark'] = ''
  465. tempObj['dealer'] = ''
  466. tempObj['manufacturer'] = ''
  467. tempObj['good_unit'] = ''
  468. tempObj['specification_name'] = ''
  469. tempObj['name'] = ''
  470. tempObj['license_number'] = ""
  471. tempObj["packing_price"] = ""
  472. this.recordInfo.recordData.push(tempObj)
  473. }, handleDelete: function(index, row) {
  474. if (this.recordInfo.recordData.length <= 1) {
  475. this.$message.error('只有一条记录的时候无法删除')
  476. return
  477. } else {
  478. this.recordInfo.recordData.splice(index, 1)
  479. }
  480. }, calculate: function(val) {
  481. if (val == 0) {
  482. return ''
  483. }
  484. return Math.round(parseFloat(val) * 100) / 100
  485. },
  486. GetWarehouseInfoByOrdeNumber: function() {
  487. const params = {
  488. 'warehousing_order': sessionStorage.getItem('warehousing_orders')
  489. }
  490. this.recordInfo.recordData = []
  491. getWarehouseInfoByOrdeNumber(params).then(response => {
  492. if (response.data.state != 0) {
  493. for (let i = 0; i < response.data.data.info.length; i++) {
  494. this.recordInfo.recordData.push(response.data.data.info[i])
  495. }
  496. console.log("333333333",this.recordInfo.recordData)
  497. }
  498. })
  499. }, getTime(val, temp) {
  500. if (val != 0) {
  501. return uParseTime(val, temp)
  502. } else {
  503. return ''
  504. }
  505. },
  506. showDialog(index, row) {
  507. const loading = this.$loading({
  508. lock: true,
  509. text: 'Loading',
  510. spinner: 'el-icon-loading',
  511. background: 'rgba(0, 0, 0, 0.7)'
  512. })
  513. this.currentIndex = index
  514. this.isVisibility = true
  515. const params = {
  516. manufacturer_id: this.form.manufacturer,
  517. dealer_id: this.form.dealer
  518. }
  519. this.propForm.goods = []
  520. GetAllGoodInfoByID(params).then(response => {
  521. if (response.data.state == 0) {
  522. this.$message.error(response.data.msg)
  523. return false
  524. loading.close()
  525. } else {
  526. loading.close()
  527. if (response.data.data.goodInfo.length <= 0) {
  528. this.$message.error('该厂商或经销商没有物品信息')
  529. return
  530. }
  531. this.$refs.dialog.show()
  532. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  533. this.propForm.goodType.push(response.data.data.goodInfo[i].type)
  534. }
  535. const obj = {}
  536. this.propForm.goodType = this.propForm.goodType.reduce((cur, next) => {
  537. obj[next.id] ? '' : obj[next.id] = true && cur.push(next)
  538. return cur
  539. }, []) // 设置cur默认类型为数组,并且初始值为空的数组
  540. }
  541. for (let i = 0; i < this.propForm.goodType.length; i++) {
  542. let goodInfo = []
  543. let goodObj = {}
  544. for (let a = 0; a < response.data.data.goodInfo.length; a++) {
  545. var respObj = response.data.data.goodInfo[a]
  546. respObj['isSelected'] = false
  547. if (respObj.type.id == this.propForm.goodType[i].id) {
  548. goodInfo.push(respObj)
  549. }
  550. }
  551. const obj = {}
  552. goodInfo = goodInfo.reduce((cur, next) => {
  553. obj[next.id] ? '' : obj[next.id] = true && cur.push(next)
  554. return cur
  555. }, []) // 设置cur默认类型为数组,并且初始值为空的数组
  556. this.$set(goodObj, this.propForm.goodType[i].id, goodInfo)
  557. this.propForm.goods.push(goodObj)
  558. }
  559. console.log( this.propForm.goods)
  560. }
  561. )
  562. },
  563. getSummaries(param) {
  564. const { columns, data } = param
  565. const sums = []
  566. columns.forEach((column, index) => {
  567. if (index === 0) {
  568. sums[index] = '总价'
  569. return
  570. }
  571. const values = data.map(item => Number(item[column.property]))
  572. if (!values.every(value => isNaN(value))) {
  573. sums[index] = values.reduce((prev, curr) => {
  574. const value = Number(curr)
  575. if (!isNaN(value)) {
  576. return prev + curr
  577. } else {
  578. return prev
  579. }
  580. }, 0)
  581. sums[index] += ' 元'
  582. } else {
  583. sums[index] = 'N/A'
  584. }
  585. })
  586. return sums
  587. }
  588. ,
  589. back() {
  590. this.$router.go(-1)
  591. }
  592. ,
  593. submit() {
  594. console.log("res23322332",this.$refs)
  595. this.$refs['tableForm'].validate((valid) => {
  596. if (valid) {
  597. this.loading = true
  598. const array = this.recordInfo.recordData
  599. console.log("array9999999",array)
  600. for (let i = 0; i < array.length; i++) {
  601. if (array[i].good_type_id == 0) {
  602. this.$message.error('商品类型不能为空')
  603. return
  604. }
  605. array[i].price = array[i].price.toString()
  606. array[i].packing_price = array[i].packing_price.toString()
  607. }
  608. if(this.recordInfo.recordData.length <= 0){
  609. this.$message.success('请添加入库商品')
  610. return
  611. }
  612. for(let i=0;i<this.recordInfo.recordData.length;i++){
  613. if(this.recordInfo.recordData[i].dealer == ""){
  614. this.recordInfo.recordData[i].dealer = 0
  615. }
  616. for(let j=0;j<this.manufacturerList.length;j++){
  617. if(this.recordInfo.recordData[i].manufacturer == this.manufacturerList[j].manufacturer_name){
  618. this.recordInfo.recordData[i].manufacturer = this.manufacturerList[j].id
  619. }
  620. }
  621. }
  622. for(let i=0;i<this.recordInfo.recordData.length;i++){
  623. for(let j=0;j<this.dealerList.length;j++){
  624. if(this.recordInfo.recordData[i].dealer == this.dealerList[j].dealer_name){
  625. this.recordInfo.recordData[i].dealer = this.dealerList[j].id
  626. }
  627. }
  628. }
  629. const loading = this.$loading({
  630. lock: true,
  631. text: 'Loading',
  632. spinner: 'el-icon-loading',
  633. background: 'rgba(0, 0, 0, 0.7)'
  634. })
  635. const params = {
  636. 'stockIn': this.recordInfo.recordData
  637. }
  638. console.log("stockIn",this.recordInfo.recordData)
  639. postWarehouse(params, this.warehousing_time, this.form.manufacturer, this.form.dealer, this.type).then(response => {
  640. if (response.data.state == 0) {
  641. this.loading = false
  642. this.$message.error(response.data.msg)
  643. loading.close()
  644. return false
  645. } else {
  646. loading.close()
  647. this.loading = false
  648. this.$message.success('入库成功')
  649. this.$router.back(-1)
  650. }
  651. })
  652. } else {
  653. return false
  654. }
  655. })
  656. }
  657. ,
  658. changeManufacturer(val) {
  659. },
  660. changeDealer(val) {
  661. },
  662. getDataConfig(module, filed_name){
  663. return getDataConfig(module, filed_name)
  664. },
  665. querySearchAsync(keyword, cb) {
  666. let key = '';
  667. if (keyword != undefined) {
  668. key = keyword
  669. }
  670. postSearchGoodList(key).then(response => {
  671. if (response.data.state == 1) {
  672. var list = response.data.data.list
  673. this.goodList = list
  674. var manufacturerList = response.data.data.manufacturerList
  675. this.manufacturerList = manufacturerList
  676. var dealer = response.data.data.dealerList
  677. this.dealerList = dealer
  678. for(let i=0;i<this.goodList.length;i++){
  679. for(let j=0;j<this.manufacturerList.length;j++){
  680. if(this.goodList[i].manufacturer == this.manufacturerList[j].id){
  681. this.goodList[i].manufacturer = this.manufacturerList[j].manufacturer_name
  682. }
  683. }
  684. }
  685. for(let i=0;i<this.goodList.length;i++){
  686. for(let j=0;j<this.dealerList.length;j++){
  687. if(this.goodList[i].dealer == this.dealerList[j].id){
  688. this.goodList[i].dealer = this.dealerList[j].dealer_name
  689. }
  690. }
  691. }
  692. cb(this.goodList)
  693. } else {
  694. cb([])
  695. }
  696. })
  697. },
  698. changeGoodName(val){
  699. this.currentIndex = val
  700. },
  701. handleSelect(val){
  702. console.log("val3232232323",val)
  703. for(let i=0;i<this.recordInfo.recordData.length;i++){
  704. if(this.currentIndex == i){
  705. this.recordInfo.recordData[i].good_type_id = val.id
  706. this.recordInfo.recordData[i].good_name = val.good_name
  707. this.recordInfo.recordData[i].good_type_id = val.good_type_id
  708. this.recordInfo.recordData[i].name = val.specification_name +"/"+val.packing_unit
  709. // this.recordInfo.recordData[i].number = val.number
  710. this.recordInfo.recordData[i].manufacturer = val.manufacturer
  711. this.recordInfo.recordData[i].remark = val.remark
  712. if(val.buy_price == 0){
  713. this.recordInfo.recordData[i].price = ""
  714. }else{
  715. this.recordInfo.recordData[i].price = val.buy_price
  716. }
  717. if(val.packing_price == 0){
  718. this.recordInfo.recordData[i].packing_price = ""
  719. }else{
  720. this.recordInfo.recordData[i].packing_price = val.packing_price
  721. }
  722. this.recordInfo.recordData[i].specification_name = val.specification_name
  723. this.recordInfo.recordData[i].good_id = val.id
  724. this.recordInfo.recordData[i].packing_unit = val.packing_unit
  725. if(val.dealer == 0){
  726. this.recordInfo.recordData[i].dealer = ""
  727. }else{
  728. this.recordInfo.recordData[i].dealer = val.dealer
  729. }
  730. }
  731. }
  732. }
  733. }
  734. ,
  735. created() {
  736. var nowDate = new Date()
  737. var nowYear = nowDate.getFullYear()
  738. var nowMonth = nowDate.getMonth() + 1
  739. var nowDay = nowDate.getDate()
  740. this.warehousing_time =
  741. nowYear +
  742. '-' +
  743. (nowMonth < 10 ? '0' + nowMonth : nowMonth) +
  744. '-' +
  745. (nowDay < 10 ? '0' + nowDay : nowDay)
  746. const tempObj = {}
  747. tempObj['good_type_id'] = 0
  748. tempObj['good_id'] = 0
  749. tempObj['number'] = ''
  750. tempObj['product_date'] = ''
  751. tempObj['expiry_date'] = ''
  752. tempObj['warehousing_count'] = ''
  753. tempObj['price'] = ''
  754. tempObj['remark'] = ''
  755. tempObj['dealer'] = ''
  756. tempObj['manufacturer'] = ''
  757. tempObj['good_unit'] = ''
  758. tempObj['good_name'] = ''
  759. tempObj['specification_name'] = ''
  760. tempObj['name'] = ''
  761. tempObj['license_number'] = ''
  762. tempObj['packing_price']= ''
  763. this.recordInfo.recordData.push(tempObj)
  764. this.GetConfigInfo()
  765. this.propForm.goodUnit = this.$store.getters.good_unit
  766. console.log("单位",this.getDataConfig('hemodialysis','units'))
  767. }
  768. }
  769. </script>
  770. <style>
  771. #oictable ::-webkit-scrollbar {
  772. height: 15px;
  773. }
  774. </style>
  775. <style rel="stylesheet/css" lang="scss" scoped>
  776. .information {
  777. border: 1px #dcdfe6 solid;
  778. padding: 30px 20px 30px 20px;
  779. .border {
  780. border-bottom: 1px #dcdfe6 solid;
  781. margin: 0px 0 20px 0;
  782. }
  783. }
  784. .edit_separater {
  785. border-top: 1px solid rgb(233, 233, 233);
  786. margin-top: 15px;
  787. margin-bottom: 15px;
  788. }
  789. </style>
  790. <style>
  791. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  792. font-size: 12px;
  793. }
  794. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  795. background: #6fb5fa;
  796. }
  797. .el-autocomplete-suggestion{
  798. width: 400px !important;
  799. }
  800. </style>