stockInOrderAdd.vue 43KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233
  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" v-loading="loading">保 存</el-button>
  9. <el-button size="small" type="primary" v-show="showCheck" @click="toCheck()" class="filter-item">审 核</el-button>
  10. <!-- <el-button size="small" type="primary" v-show="showReturnCheck" @click="toReturnCheck()" class="filter-item">反 审 核</el-button> -->
  11. </div>
  12. </div>
  13. <div class="app-container" v-loading="loading">
  14. <stock-in-dialog ref="dialog" :propForm="propForm"
  15. :visibility="isVisibility"
  16. v-on:dialog-comfirm="comfirm"
  17. v-on:dialog-cancle="cancle">
  18. </stock-in-dialog>
  19. <div class="cell clearfix">
  20. <label class="title"><span class="name"><span style="color:red">*</span>仓库</span> :</label>
  21. <el-select size="small" v-model="storehouse_id" filterable placeholder="请选择仓库" style="width:200px">
  22. <el-option
  23. v-for="(option, index) in list"
  24. :key="index"
  25. :label="option.storehouse_name"
  26. :value="option.id">
  27. </el-option>
  28. </el-select>
  29. <label class="title"><span class="name">入库时间</span> : </label>
  30. <el-date-picker size="small" v-model="warehousing_time" prefix-icon="el-icon-date" :editable="false"
  31. style="width: 196px;" type="date" placeholder="选择日期时间" align="right" format="yyyy-MM-dd"
  32. value-format="yyyy-MM-dd"></el-date-picker>
  33. </div>
  34. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  35. <el-table id="oictable" :data="recordInfo.recordData" :class="signAndWeighBoxPatients" border
  36. style="width: 100%"
  37. max-height="450" :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  38. >
  39. <el-table-column align="center" width="200" fixed="left">
  40. <template slot="header" slot-scope="scope">
  41. <span>耗材名称</span>
  42. </template>
  43. <template slot-scope="scope">
  44. <el-autocomplete
  45. class="checkSearch"
  46. popper-class="my-autocomplete"
  47. v-model="scope.row.good_name"
  48. :fetch-suggestions="querySearchAsync"
  49. :trigger-on-focus="true"
  50. placeholder="请输入耗材名称"
  51. @select="handleSelect"
  52. @input="changeGoodName(scope.$index)"
  53. style="width:160px;"
  54. :popper-append-to-body="true"
  55. >
  56. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  57. <template slot-scope="{ item }">
  58. <div class="name">{{ item.good_name +" " +item.specification_name + " "+item.manufacturer }}</div>
  59. </template>
  60. </el-autocomplete>
  61. </template>
  62. </el-table-column>
  63. <el-table-column align="center" width="140">
  64. <template slot="header" slot-scope="scope">
  65. <span>耗材类型<span style="color: red">*</span></span>
  66. </template>
  67. <template slot-scope="scope">
  68. <el-form-item style="padding-top: 20px;">
  69. <el-input placeholder="请输入耗材类型" v-model="scope.row.good_type_id" :value="typeName(scope.row.good_type_id)"></el-input>
  70. </el-form-item>
  71. </template>
  72. </el-table-column>
  73. <el-table-column align="center" width="140">
  74. <template slot="header" slot-scope="scope">
  75. <span>规格&单位<span style="color: red">*</span></span>
  76. </template>
  77. <template slot-scope="scope">
  78. <el-form-item style="padding-top: 20px">
  79. <el-input placeholder="请输入规格名称" v-model="scope.row.name"></el-input>
  80. </el-form-item>
  81. </template>
  82. </el-table-column>
  83. <el-table-column align="center" width="150">
  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: 20px" :prop="'recordData.' + scope.$index + '.number'"
  89. :rules='tableRules.number' >
  90. <el-input placeholder="请输入批号" v-model="scope.row.number"></el-input>
  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 + '.warehousing_count'"
  100. :rules='tableRules.warehousing_count' style="padding-top: 20px">
  101. <!-- <el-input placeholder="请输入入库数量" type="number" v-model="scope.row.warehousing_count" oninput="value=value.replace(/\D|^0/g,'')"></el-input> -->
  102. <el-input placeholder="请输入入库数量" v-model="scope.row.warehousing_count"></el-input>
  103. {{scope.row.min_unit}}
  104. </el-form-item>
  105. </template>
  106. </el-table-column>
  107. <el-table-column align="center" width="200">
  108. <template slot="header" slot-scope="scope">
  109. <span>当前溯源码数量</span>
  110. </template>
  111. <template slot-scope="scope">
  112. <el-form-item
  113. :prop="'recordData.' + scope.$index + '.good_code_cnt'"
  114. style="padding-top: 10px"
  115. >
  116. <div style="display: flex">
  117. <el-input
  118. placeholder="请输入入库数量"
  119. v-model="scope.row.good_code_cnt"
  120. style="width: 120px"
  121. disabled
  122. ></el-input>
  123. </div>
  124. </el-form-item>
  125. </template>
  126. </el-table-column>
  127. <el-table-column align="center" width="120">
  128. <template slot="header" slot-scope="scope">
  129. <span>零售价<span style="color: red">*</span></span>
  130. </template>
  131. <template slot-scope="scope">
  132. <el-form-item :prop="'recordData.' + scope.$index + '.packing_price'" :rules='tableRules.packing_price'
  133. style="padding-top: 20px">
  134. <el-input placeholder="请输入单价" type="number" v-model="scope.row.packing_price"></el-input>
  135. </el-form-item>
  136. </template>
  137. </el-table-column>
  138. <el-table-column align="center" width="120">
  139. <template slot="header" slot-scope="scope">
  140. <span>进货单价<span style="color: red">*</span></span>
  141. </template>
  142. <template slot-scope="scope">
  143. <el-form-item :prop="'recordData.' + scope.$index + '.price'" :rules='tableRules.price'
  144. style="padding-top: 20px">
  145. <el-input placeholder="请输入单价" type="number" v-model="scope.row.price"></el-input>
  146. </el-form-item>
  147. </template>
  148. </el-table-column>
  149. <el-table-column label="总价" align="center" width="80">
  150. <template slot-scope="scope">
  151. {{calculate(scope.row.price*scope.row.warehousing_count)}}
  152. </template>
  153. </el-table-column>
  154. <el-table-column align="center" width="180">
  155. <template slot="header" slot-scope="scope">
  156. <span>有效日期<span style="color: red">*</span></span>
  157. </template>
  158. <template slot-scope="scope">
  159. <el-form-item :prop="'recordData.' + scope.$index + '.expiry_date'"
  160. :rules="tableRules.expiry_date">
  161. <el-date-picker prefix-icon="el-icon-date" style="width: 145px" v-model="scope.row.expiry_date"
  162. type="date" placeholder="选择日期时间" format="yyyy-MM-dd"
  163. value-format="yyyy-MM-dd">
  164. </el-date-picker>
  165. </el-form-item>
  166. </template>
  167. </el-table-column>
  168. <el-table-column label="生产日期" align="center" width="180">
  169. <template slot-scope="scope">
  170. <el-date-picker prefix-icon="el-icon-date" v-model="scope.row.product_date" style="width: 145px"
  171. type="date" placeholder="选择日期时间" format="yyyy-MM-dd"
  172. value-format="yyyy-MM-dd">
  173. </el-date-picker>
  174. </template>
  175. </el-table-column>
  176. <el-table-column label="生产厂家" align="center" width="150">
  177. <template slot-scope="scope">
  178. <el-select size="small" v-model="scope.row.manufacturer" filterable placeholder="请选择厂商">
  179. <el-option
  180. v-for="(option, index) in manufacturerList"
  181. :key="index"
  182. :label="option.manufacturer_name"
  183. :value="option.id">
  184. </el-option>
  185. </el-select>
  186. </template>
  187. </el-table-column>
  188. <el-table-column align="center" width="150" v-if="org_id!=10653&&org_id!=0">
  189. <template slot="header" slot-scope="scope">
  190. <span>批准文号</span>
  191. </template>
  192. <template slot-scope="scope">
  193. <el-form-item style="padding-top: 20px">
  194. <el-input placeholder="请输入批准文号" v-model="scope.row.license_number" ></el-input>
  195. </el-form-item>
  196. </template>
  197. </el-table-column>
  198. <el-table-column align="center" width="150" v-if="org_id ==10653 || org_id == 0">
  199. <template slot="header" slot-scope="scope">
  200. <span>生产许可证号</span>
  201. </template>
  202. <template slot-scope="scope">
  203. <el-form-item style="padding-top: 20px">
  204. <el-input placeholder="请输入生产许可证号" v-model="scope.row.license_number" ></el-input>
  205. </el-form-item>
  206. </template>
  207. </el-table-column>
  208. <el-table-column align="center" width="150">
  209. <template slot="header" slot-scope="scope">
  210. <span>注册编码</span>
  211. </template>
  212. <template slot-scope="scope">
  213. <el-form-item style="padding-top: 20px">
  214. <el-input placeholder="请输入注册编码" v-model="scope.row.register_number" ></el-input>
  215. </el-form-item>
  216. </template>
  217. </el-table-column>
  218. <el-table-column label="经销商" align="center" width="150">
  219. <template slot-scope="scope">
  220. <el-select size="small" v-model="scope.row.dealer" filterable placeholder="请选择厂商">
  221. <el-option
  222. v-for="(option, index) in dealerList"
  223. :key="index"
  224. :label="option.dealer_name"
  225. :value="option.id">
  226. </el-option>
  227. </el-select>
  228. </template>
  229. </el-table-column>
  230. <el-table-column label="耗材追溯码" align="center" width="150">
  231. <template slot-scope="scope">
  232. <div @click="changeGoodCode(scope.row,scope.$index)">
  233. <el-input v-model="scope.row.good_code" placeholder="请输入耗材追溯码"></el-input>
  234. </div>
  235. </template>
  236. </el-table-column>
  237. <el-table-column label="追溯码数量" align="center" width="150">
  238. <template slot-scope="scope">
  239. {{ getGoodCode(scope.row.good_code) }}
  240. </template>
  241. </el-table-column>
  242. <el-table-column label="备注" align="center" width="150">
  243. <template slot-scope="scope">
  244. <el-input placeholder="请输入备注" v-model="scope.row.remark"></el-input>
  245. </template>
  246. </el-table-column>
  247. <el-table-column label="操作" align="center" fixed="right" width="150">
  248. <template slot-scope="scope">
  249. <el-tooltip class="item" effect="dark" content="新增" placement="top">
  250. <el-button
  251. size="mini"
  252. type="primary"
  253. icon="el-icon-circle-plus-outline"
  254. @click="handleEdit(scope.$index, scope.row)">
  255. </el-button>
  256. </el-tooltip>
  257. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  258. <el-button
  259. size="mini"
  260. type="danger"
  261. icon="el-icon-delete"
  262. @click="handleDelete(scope.$index, scope.row)">
  263. </el-button>
  264. </el-tooltip>
  265. </template>
  266. </el-table-column>
  267. </el-table>
  268. <div style="margin-top: 20px;">合计金额: {{getTotalPirce() }} </div>
  269. </el-form>
  270. </div>
  271. <el-dialog
  272. title="耗材追溯码"
  273. @open="openDialog"
  274. :visible.sync="dialogVisible"
  275. width="40%">
  276. <div style="margin-bottom: 10px;">
  277. <span >追溯码个数:{{getTotal() }} 个</span>
  278. </div>
  279. <span>
  280. <el-input
  281. ref="inputRef"
  282. @keyup.native="changeText"
  283. type="textarea"
  284. placeholder="请输入内容"
  285. v-model="textarea"
  286. :rows="10"
  287. >
  288. </el-input>
  289. </span>
  290. <span slot="footer" class="dialog-footer">
  291. <el-button @click="dialogVisible = false">取 消</el-button>
  292. <el-button type="primary" @click="saveTextArea()">确 定</el-button>
  293. </span>
  294. </el-dialog>
  295. </div>
  296. </template>
  297. <script>
  298. import stockInDialog from './Dialog/stockInDialog'
  299. import { uParseTime } from '@/utils/tools'
  300. import {getDataConfig } from "@/utils/data";
  301. import {
  302. deleteWarehouseInfo,
  303. GetAllConfig,
  304. GetAllGoodInfo,
  305. GetAllGoodInfoByID,
  306. GetAllGoodType,
  307. getWarehouseInfoByOrdeNumber,
  308. modifyWarehouseInfo,
  309. postWarehouse,
  310. postSearchGoodList,
  311. toCheckWarehouseInfo,
  312. toReturnCheckWarehouseInfo
  313. } from '@/api/stock'
  314. import BreadCrumb from '../components/bread-crumb'
  315. export default {
  316. components: { BreadCrumb, stockInDialog },
  317. name: 'stockIn',
  318. data() {
  319. var checkGoodId = (rule, value, callback) => {
  320. setTimeout(() => {
  321. if (value == '' || value == 0) {
  322. return callback(new Error('规格名称不能为空'))
  323. }
  324. }, 2000)
  325. }
  326. return {
  327. crumbs: [
  328. { path: false, name: '库存管理' },
  329. { path: false, name: '耗材入库单' },
  330. { path: false, name: '新增入库单' }
  331. ],
  332. crumbs2: [
  333. { path: false, name: '库存管理' },
  334. { path: false, name: '其他入库单' },
  335. { path: false, name: '新增入库单' }
  336. ],
  337. signAndWeighBoxPatients: 'sign-and-weigh-box-patients',
  338. warehousing_time: '',
  339. adminUserOptions: null,
  340. currentIndex: 0,
  341. recordInfo: {
  342. recordData: [],
  343. stock_in_code: '',
  344. current_index: ''
  345. },
  346. tableRules: {
  347. price: [
  348. { required: true, message: '单价不能为空', trigger: 'blur' }
  349. ],
  350. packing_price: [
  351. { required: true, message: '零售价不能为空', trigger: 'blur' }
  352. ],
  353. warehousing_count: [
  354. { required: true, message: '数量不能为空', trigger: 'blur' }
  355. ],
  356. good_id: [
  357. { validator: checkGoodId, trigger: 'blur' }
  358. ],
  359. number:[
  360. { required: true, message: '批号不能为空', trigger: 'blur' }
  361. ],
  362. expiry_date:[
  363. { required: true, message: '有效日期不能为空', trigger: 'blur' }
  364. ],
  365. },
  366. type: this.$route.query.type,
  367. total: '',
  368. product_date: '',
  369. expiry_date: '',
  370. numbers: '',
  371. // prop
  372. isVisibility: false,
  373. propForm: {
  374. goods: [],
  375. goodType: [],
  376. goodInfo: [],
  377. goodUnit: [],
  378. title: '入库',
  379. formValue: {
  380. good_type_id: '',
  381. good_id: '',
  382. number: '',
  383. product_date: '',
  384. expiry_date: '',
  385. warehousing_count: '',
  386. price: '',
  387. remark: '',
  388. dealer: '',
  389. manufacturer: '',
  390. good_code:"",
  391. good_code_count:""
  392. },
  393. isCreated: 1
  394. },
  395. goodInfo: {
  396. loading: false,
  397. goodTypeData: [],
  398. type_code: ''
  399. },
  400. form: {
  401. manufacturer: '',
  402. dealer: ''
  403. },
  404. formValue: {
  405. good_type_id: '',
  406. good_id: '',
  407. number: '',
  408. product_date: '',
  409. expiry_date: '',
  410. warehousing_count: '',
  411. price: '',
  412. remark: '',
  413. dealer: '',
  414. manufacturer: ''
  415. },
  416. manufacturer: [],
  417. dealerList: [],
  418. goodType: [],
  419. manufacturerList:[],
  420. goodList:[],
  421. loading:false,
  422. list:[],
  423. storehouse_id:"",
  424. showCheck:false,
  425. showReturnCheck:false,
  426. warehousing_info_id:0,
  427. org_id:0,
  428. dialogVisible:false,
  429. currentRow:{},
  430. currentIndex:0,
  431. textarea:"",
  432. }
  433. },
  434. methods: {
  435. getTotal(){
  436. if(this.textarea!=null){
  437. var textAreaList = this.textarea.split(",")
  438. console.log("textArrleti",textAreaList)
  439. var arr = []
  440. if(textAreaList!=null && textAreaList.length>0){
  441. for(let i=0;i<textAreaList.length;i++){
  442. if(textAreaList[i]!=""){
  443. arr.push(textAreaList[i])
  444. }
  445. }
  446. return arr.length
  447. }else{
  448. return ""
  449. }
  450. }
  451. },
  452. openDialog(){
  453. this.$nextTick(() => {
  454. this.$refs.inputRef.focus()
  455. });
  456. },
  457. handleSave: function() {
  458. if (this.recordInfo.recordData.length <= 0) {
  459. this.$message.error('请添加入库信息')
  460. return
  461. }
  462. sessionStorage.removeItem('warehousing_orders')
  463. this.$router.back(-1)
  464. }, handleCancle: function() {
  465. this.$confirm('是否放弃编辑返回上一页?', '放弃编辑', {
  466. confirmButtonText: '确定',
  467. cancelButtonText: '取消',
  468. type: 'warning'
  469. }).then(() => {
  470. sessionStorage.removeItem('warehousing_orders')
  471. this.$router.back(-1)
  472. }).catch(() => {
  473. })
  474. }, handleCreate: function() {
  475. this.propForm.formValue = {}
  476. this.propForm.isCreated = 1
  477. this.isVisibility = true
  478. },
  479. comfirm: function(val) {
  480. this.propForm.goodType = []
  481. this.propForm.goods = []
  482. this.$refs.dialog.hide()
  483. console.log(val)
  484. if (val.selectedGoodInfo.length > 0) {
  485. for (let i = val.selectedGoodInfo.length - 1; i >= 0; i--) {
  486. if (i == 0) {
  487. this.recordInfo.recordData[this.currentIndex].good_type_id = val.selectedGoodInfo[i].good_type_id
  488. this.recordInfo.recordData[this.currentIndex].good_id = val.selectedGoodInfo[i].id
  489. this.recordInfo.recordData[this.currentIndex].price = val.selectedGoodInfo[i].buy_price.toString()
  490. this.recordInfo.recordData[this.currentIndex].good_unit = val.selectedGoodInfo[i].good_unit
  491. this.recordInfo.recordData[this.currentIndex].good_name = val.selectedGoodInfo[i].good_name
  492. } else {
  493. const tempForm = {}
  494. tempForm['good_type_id'] =val.selectedGoodInfo[i].good_type_id
  495. tempForm['good_id'] = val.selectedGoodInfo[i].id
  496. tempForm['number'] = ''
  497. tempForm['product_date'] = ''
  498. tempForm['expiry_date'] = ''
  499. tempForm['warehousing_count'] = ''
  500. tempForm['price'] = val.selectedGoodInfo[i].buy_price.toString()
  501. tempForm['remark'] = ''
  502. tempForm['dealer'] = ''
  503. tempForm['manufacturer'] = ''
  504. tempForm['good_unit'] = val.selectedGoodInfo[i].good_unit
  505. tempForm['good_name'] = val.selectedGoodInfo[i].good_name
  506. this.recordInfo.recordData.splice(this.currentIndex + 1, 0, tempForm)
  507. }
  508. }
  509. }
  510. this.currentIndex = -1
  511. }, cancle: function() {
  512. this.propForm.goodType = []
  513. this.propForm.goods = []
  514. this.$refs.dialog.hide()
  515. },
  516. GetAllGoodType: function() {
  517. GetAllGoodType().then(response => {
  518. if (response.data.state == 0) {
  519. this.$message.error(response.data.msg)
  520. return false
  521. } else {
  522. for (let i = 0; i < response.data.data.goodType.length; i++) {
  523. this.propForm.goodType.push(response.data.data.goodType[i])
  524. }
  525. }
  526. })
  527. },
  528. GetAllGoodInfo: function() {
  529. GetAllGoodInfo().then(response => {
  530. if (response.data.state == 0) {
  531. this.$message.error(response.data.msg)
  532. return false
  533. } else {
  534. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  535. this.propForm.goodInfo.push(response.data.data.goodInfo[i])
  536. }
  537. }
  538. })
  539. },
  540. GetConfigInfo: function() {
  541. const loading = this.$loading({
  542. lock: true,
  543. text: 'Loading',
  544. spinner: 'el-icon-loading',
  545. background: 'rgba(0, 0, 0, 0.7)'
  546. })
  547. GetAllConfig().then(response => {
  548. if (response.data.state == 0) {
  549. this.$message.error(response.data.msg)
  550. return false
  551. } else {
  552. this.manufacturer = response.data.data.manufacturer
  553. this.dealer = response.data.data.dealer
  554. this.goodType = response.data.data.goodType
  555. this.goodInfo = response.data.data.goodInfo
  556. this.manufacturer.splice(0, 0, { id: 0, manufacturer_name: '全部' })
  557. this.dealer.splice(0, 0, { id: 0, dealer_name: '全部' })
  558. this.manufacturer.splice(0, 0, { id: -1, manufacturer_name: '其他' })
  559. this.dealer.splice(0, 0, { id: -1, dealer_name: '其他' })
  560. this.form.manufacturer = 0
  561. this.form.dealer = 0
  562. this.list = response.data.data.list
  563. this.storehouse_id = response.data.data.configlist.storehouse_info
  564. }
  565. loading.close()
  566. })
  567. }, typeName: function(good_type_id) {
  568. let name = ''
  569. for (let i = 0; i < this.goodType.length; i++) {
  570. if (this.goodType[i].id == good_type_id) {
  571. name = this.goodType[i].type_name
  572. }
  573. }
  574. return name
  575. }, specificationName: function(good_info_id) {
  576. let name = ''
  577. for (let i = 0; i < this.goodInfo.length; i++) {
  578. if (this.goodInfo[i].id == good_info_id) {
  579. name = this.goodInfo[i].specification_name
  580. }
  581. }
  582. return name
  583. },
  584. handleEdit: function(index, row) {
  585. const tempObj = {}
  586. tempObj['good_type_id'] = 0
  587. tempObj['good_id'] = 0
  588. tempObj['number'] = ''
  589. tempObj['product_date'] = ''
  590. tempObj['expiry_date'] = ''
  591. tempObj['warehousing_count'] = ''
  592. tempObj['price'] = ''
  593. tempObj['remark'] = ''
  594. tempObj['dealer'] = ''
  595. tempObj['manufacturer'] = ''
  596. tempObj['good_unit'] = ''
  597. tempObj['specification_name'] = ''
  598. tempObj['name'] = ''
  599. tempObj['license_number'] = ""
  600. tempObj["packing_price"] = ""
  601. tempObj["id"] = 0
  602. tempObj['register_number'] = ''
  603. tempObj['good_code'] = ""
  604. tempObj['good_code_cnt'] = ''
  605. tempObj["good_code_count"] =''
  606. this.recordInfo.recordData.push(tempObj)
  607. }, handleDelete: function(index, row) {
  608. if (this.recordInfo.recordData.length <= 1) {
  609. this.$message.error('只有一条记录的时候无法删除')
  610. return
  611. } else {
  612. this.recordInfo.recordData.splice(index, 1)
  613. }
  614. },
  615. calculate: function(val) {
  616. if (val == 0) {
  617. return ''
  618. }
  619. return Math.round(parseFloat(val) * 100) / 100
  620. },
  621. GetWarehouseInfoByOrdeNumber: function() {
  622. const params = {
  623. 'warehousing_order': sessionStorage.getItem('warehousing_orders')
  624. }
  625. this.recordInfo.recordData = []
  626. getWarehouseInfoByOrdeNumber(params).then(response => {
  627. if (response.data.state != 0) {
  628. for (let i = 0; i < response.data.data.info.length; i++) {
  629. this.recordInfo.recordData.push(response.data.data.info[i])
  630. }
  631. console.log("333333333",this.recordInfo.recordData)
  632. }
  633. })
  634. }, getTime(val, temp) {
  635. if (val != 0) {
  636. return uParseTime(val, temp)
  637. } else {
  638. return ''
  639. }
  640. },
  641. showDialog(index, row) {
  642. const loading = this.$loading({
  643. lock: true,
  644. text: 'Loading',
  645. spinner: 'el-icon-loading',
  646. background: 'rgba(0, 0, 0, 0.7)'
  647. })
  648. this.currentIndex = index
  649. this.isVisibility = true
  650. const params = {
  651. manufacturer_id: this.form.manufacturer,
  652. dealer_id: this.form.dealer
  653. }
  654. this.propForm.goods = []
  655. GetAllGoodInfoByID(params).then(response => {
  656. if (response.data.state == 0) {
  657. this.$message.error(response.data.msg)
  658. return false
  659. loading.close()
  660. } else {
  661. loading.close()
  662. if (response.data.data.goodInfo.length <= 0) {
  663. this.$message.error('该厂商或经销商没有物品信息')
  664. return
  665. }
  666. this.$refs.dialog.show()
  667. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  668. this.propForm.goodType.push(response.data.data.goodInfo[i].type)
  669. }
  670. const obj = {}
  671. this.propForm.goodType = this.propForm.goodType.reduce((cur, next) => {
  672. obj[next.id] ? '' : obj[next.id] = true && cur.push(next)
  673. return cur
  674. }, []) // 设置cur默认类型为数组,并且初始值为空的数组
  675. }
  676. for (let i = 0; i < this.propForm.goodType.length; i++) {
  677. let goodInfo = []
  678. let goodObj = {}
  679. for (let a = 0; a < response.data.data.goodInfo.length; a++) {
  680. var respObj = response.data.data.goodInfo[a]
  681. respObj['isSelected'] = false
  682. if (respObj.type.id == this.propForm.goodType[i].id) {
  683. goodInfo.push(respObj)
  684. }
  685. }
  686. const obj = {}
  687. goodInfo = goodInfo.reduce((cur, next) => {
  688. obj[next.id] ? '' : obj[next.id] = true && cur.push(next)
  689. return cur
  690. }, []) // 设置cur默认类型为数组,并且初始值为空的数组
  691. this.$set(goodObj, this.propForm.goodType[i].id, goodInfo)
  692. this.propForm.goods.push(goodObj)
  693. }
  694. console.log( this.propForm.goods)
  695. }
  696. )
  697. },
  698. getSummaries(param) {
  699. const { columns, data } = param
  700. const sums = []
  701. columns.forEach((column, index) => {
  702. if (index === 0) {
  703. sums[index] = '总价'
  704. return
  705. }
  706. const values = data.map(item => Number(item[column.property]))
  707. if (!values.every(value => isNaN(value))) {
  708. sums[index] = values.reduce((prev, curr) => {
  709. const value = Number(curr)
  710. if (!isNaN(value)) {
  711. return prev + curr
  712. } else {
  713. return prev
  714. }
  715. }, 0)
  716. sums[index] += ' 元'
  717. } else {
  718. sums[index] = 'N/A'
  719. }
  720. })
  721. return sums
  722. }
  723. ,
  724. back() {
  725. this.$router.go(-1)
  726. }
  727. ,
  728. submit() {
  729. this.$refs['tableForm'].validate((valid) => {
  730. if (valid) {
  731. this.loading = true
  732. const array = this.recordInfo.recordData
  733. if(this.storehouse_id == 0){
  734. this.$message.error("仓库不能为空!")
  735. return
  736. }
  737. for (let i = 0; i < array.length; i++) {
  738. if (array[i].good_type_id == 0) {
  739. this.$message.error('商品类型不能为空')
  740. return
  741. }
  742. array[i].price = array[i].price.toString()
  743. array[i].packing_price = array[i].packing_price.toString()
  744. }
  745. if(this.$store.getters.xt_user.org_id == 10138 || this.$store.getters.xt_user.org_id == 10278 || this.$store.getters.xt_user.org_id == 10610 || this.$store.getters.xt_user.org_id == 10537 ) {
  746. for (let i = 0; i < array.length; i++) {
  747. if (array[i].good_code.length == 0) {
  748. this.$message.error(array[i].good_name + " 溯源码不能为空");
  749. this.loading = false;
  750. return;
  751. }
  752. var aaa = array[i].good_code.split(",")
  753. if(new Set(aaa).size !== aaa.length){
  754. this.$message.error( array[i].good_name + " 溯源码不能重复");
  755. this.loading = false;
  756. return;
  757. }
  758. }
  759. }
  760. if(this.recordInfo.recordData.length <= 0){
  761. this.$message.success('请添加入库商品')
  762. return
  763. }
  764. for(let i=0;i<this.recordInfo.recordData.length;i++){
  765. if(this.recordInfo.recordData[i].dealer == ""){
  766. this.recordInfo.recordData[i].dealer = 0
  767. }
  768. for(let j=0;j<this.manufacturerList.length;j++){
  769. if(this.recordInfo.recordData[i].manufacturer == this.manufacturerList[j].manufacturer_name){
  770. this.recordInfo.recordData[i].manufacturer = this.manufacturerList[j].id
  771. }
  772. }
  773. }
  774. for(let i=0;i<this.recordInfo.recordData.length;i++){
  775. for(let j=0;j<this.dealerList.length;j++){
  776. if(this.recordInfo.recordData[i].dealer == this.dealerList[j].dealer_name){
  777. this.recordInfo.recordData[i].dealer = this.dealerList[j].id
  778. }
  779. }
  780. this.recordInfo.recordData[i].warehousing_count = this.recordInfo.recordData[i].warehousing_count.toString()
  781. }
  782. const loading = this.$loading({
  783. lock: true,
  784. text: 'Loading',
  785. spinner: 'el-icon-loading',
  786. background: 'rgba(0, 0, 0, 0.7)'
  787. })
  788. const params = {
  789. 'stockIn': this.recordInfo.recordData
  790. }
  791. console.log("param232232323232323w",params)
  792. postWarehouse(params, this.warehousing_time, this.type,this.storehouse_id,this.warehousing_info_id).then(response => {
  793. if (response.data.state == 0) {
  794. this.loading = false
  795. this.$message.error(response.data.msg)
  796. loading.close()
  797. return false
  798. } else {
  799. loading.close()
  800. this.loading = false
  801. this.$message.success('保存成功')
  802. var list = response.data.data.list
  803. console.log("list2332323323",list)
  804. var dealerList = response.data.data.dealerList
  805. var manufacturerList = response.data.data.manufacturerList
  806. var info = response.data.data.info
  807. this.warehousing_info_id = info.id
  808. for(let i=0;i<list.length;i++){
  809. for(let j=0;j<dealerList.length;j++){
  810. if(list[i].dealer == dealerList[j].id){
  811. list[i].dealer = dealerList[j].dealer_name
  812. }
  813. }
  814. for(let s=0;s<manufacturerList.length;s++){
  815. if(list[i].manufacturer == manufacturerList[s].id){
  816. list[i].manufacturer = manufacturerList[s].manufacturer_name
  817. }
  818. }
  819. list[i].expiry_date = this.getTimeOne(list[i].expiry_date)
  820. list[i].product_date = this.getTimeOne(list[i].product_date)
  821. list[i].good_name = list[i].GoodInfo.good_name
  822. list[i].name = list[i].GoodInfo.specification_name +"/"+ list[i].GoodInfo.packing_unit
  823. list[i].good_code = list[i].good_code
  824. }
  825. this.recordInfo.recordData = []
  826. this.recordInfo.recordData = list
  827. this.showCheck = true
  828. // this.$router.back(-1)
  829. }
  830. })
  831. } else {
  832. return false
  833. }
  834. })
  835. }
  836. ,
  837. changeManufacturer(val) {
  838. },
  839. changeDealer(val) {
  840. },
  841. getDataConfig(module, filed_name){
  842. return getDataConfig(module, filed_name)
  843. },
  844. querySearchAsync(keyword, cb) {
  845. let key = '';
  846. if (keyword != undefined) {
  847. key = keyword
  848. }
  849. postSearchGoodList(key,this.storehouse_id).then(response => {
  850. if (response.data.state == 1) {
  851. var list = response.data.data.list
  852. this.goodList = list
  853. var manufacturerList = response.data.data.manufacturerList
  854. this.manufacturerList = manufacturerList
  855. var dealer = response.data.data.dealerList
  856. this.dealerList = dealer
  857. for(let i=0;i<this.goodList.length;i++){
  858. for(let j=0;j<this.manufacturerList.length;j++){
  859. if(this.goodList[i].manufacturer == this.manufacturerList[j].id){
  860. this.goodList[i].manufacturer = this.manufacturerList[j].manufacturer_name
  861. }
  862. }
  863. }
  864. for(let i=0;i<this.goodList.length;i++){
  865. for(let j=0;j<this.dealerList.length;j++){
  866. if(this.goodList[i].dealer == this.dealerList[j].id){
  867. this.goodList[i].dealer = this.dealerList[j].dealer_name
  868. }
  869. }
  870. }
  871. cb(this.goodList)
  872. } else {
  873. cb([])
  874. }
  875. })
  876. },
  877. changeGoodName(val){
  878. this.currentIndex = val
  879. },
  880. handleSelect(val){
  881. // console.log("al32323232323223",val)
  882. for(let i=0;i<this.recordInfo.recordData.length;i++){
  883. if(this.currentIndex == i){
  884. this.recordInfo.recordData[i].id = 0
  885. this.recordInfo.recordData[i].good_type_id = val.id
  886. this.recordInfo.recordData[i].good_name = val.good_name
  887. this.recordInfo.recordData[i].good_type_id = val.good_type_id
  888. this.recordInfo.recordData[i].name = val.specification_name +"/"+val.packing_unit
  889. this.recordInfo.recordData[i].manufacturer = val.manufacturer
  890. this.recordInfo.recordData[i].remark = val.remark
  891. this.recordInfo.recordData[i].license_number = val.number
  892. this.recordInfo.recordData[i].register_number = val.register_number
  893. if(val.buy_price == 0){
  894. this.recordInfo.recordData[i].price = "0"
  895. }else{
  896. this.recordInfo.recordData[i].price = val.buy_price
  897. }
  898. if(val.packing_price == 0){
  899. this.recordInfo.recordData[i].packing_price = "0"
  900. }else{
  901. this.recordInfo.recordData[i].packing_price = val.packing_price
  902. }
  903. this.recordInfo.recordData[i].specification_name = val.specification_name
  904. this.recordInfo.recordData[i].good_id = val.id
  905. this.recordInfo.recordData[i].packing_unit = val.packing_unit
  906. if(val.dealer == 0){
  907. this.recordInfo.recordData[i].dealer = ""
  908. }else{
  909. this.recordInfo.recordData[i].dealer = val.dealer
  910. }
  911. }
  912. }
  913. },
  914. getTimeOne(val) {
  915. if(val < 0){
  916. return ""
  917. }
  918. if(val == ""){
  919. return ""
  920. }else {
  921. return uParseTime(val, '{y}-{m}-{d}')
  922. }
  923. },
  924. toCheck(){
  925. const loading = this.$loading({
  926. lock: true,
  927. text: 'Loading',
  928. spinner: 'el-icon-loading',
  929. background: 'rgba(0, 0, 0, 0.7)'
  930. })
  931. var params = {
  932. warehousing_info_id:this.warehousing_info_id,
  933. }
  934. toCheckWarehouseInfo(params).then(response=>{
  935. if(response.data.state == 1){
  936. var list = response.data.data.list
  937. this.$message.success("审核成功!")
  938. this.showCheck = false
  939. this.showReturnCheck = true
  940. this.$router.back(-1)
  941. loading.close()
  942. }else{
  943. this.$message.error("审核失败")
  944. loading.close()
  945. }
  946. })
  947. },
  948. toReturnCheck(){
  949. const loading = this.$loading({
  950. lock: true,
  951. text: 'Loading',
  952. spinner: 'el-icon-loading',
  953. background: 'rgba(0, 0, 0, 0.7)'
  954. })
  955. var params = {
  956. warehousing_info_id:this.warehousing_info_id,
  957. }
  958. toReturnCheckWarehouseInfo(params).then(response=>{
  959. if(response.data.state == 1){
  960. var list = response.data.data.list
  961. this.$message.success("反审核成功!")
  962. this.showCheck = true
  963. this.showReturnCheck = false
  964. loading.close()
  965. this.$router.back(-1)
  966. }else{
  967. this.$message.error("反审核失败!")
  968. loading.close()
  969. }
  970. })
  971. },
  972. getTotalPirce(){
  973. var total_price = 0
  974. if(this.recordInfo.recordData!=null && this.recordInfo.recordData.length>0){
  975. for(let i=0;i<this.recordInfo.recordData.length;i++){
  976. total_price += this.recordInfo.recordData[i].price * parseInt(this.recordInfo.recordData[i].warehousing_count)
  977. }
  978. if(total_price>0){
  979. return total_price.toFixed(4)
  980. }else{
  981. return ""
  982. }
  983. }
  984. },
  985. changeGoodCode(row,index){
  986. this.textarea=""
  987. this.textarea = row.good_code
  988. this.currentRow = row
  989. this.currentIndex =index
  990. this.dialogVisible = true
  991. },
  992. changeText(event){
  993. var textAreaList = this.textarea.split(",")
  994. if (event.key === 'Enter') {
  995. var textarea = ""
  996. textarea += this.textarea.replace(/^\s*[\r\n]|\r?\n\s*$/gm, '') + ","
  997. var parts = textarea.split(',')
  998. for(let i=0;i<textAreaList.length;i++){
  999. if(parts[parts.length-2] == textAreaList[i]){
  1000. this.$message.error("该条码已经存在,不能重复扫码")
  1001. }
  1002. }
  1003. const uniqueStr = [...new Set(textarea.split(','))].join(',');
  1004. this.textarea = uniqueStr
  1005. }
  1006. },
  1007. saveTextArea(){
  1008. for(let i=0;i<this.recordInfo.recordData.length;i++){
  1009. if(this.currentIndex == i){
  1010. this.recordInfo.recordData[i].good_code = this.textarea
  1011. this.recordInfo.recordData[i].good_code_count = this.getTotal()
  1012. // 去除换行符
  1013. let noNewLineStr = this.textarea.replace(/\n/g, "");
  1014. // 按逗号分割成数组
  1015. let resultArray = noNewLineStr.split(",");
  1016. let arr = []
  1017. for(let c = 0; c < resultArray.length; c++){
  1018. if(resultArray[c] != ""){
  1019. arr.push(resultArray[c])
  1020. }
  1021. }
  1022. this.recordInfo.recordData[i].good_code_cnt = arr.length
  1023. }
  1024. }
  1025. this.dialogVisible = false
  1026. },
  1027. getGoodCode(val){
  1028. var newArr = []
  1029. var total = 0
  1030. if(val!=undefined){
  1031. newArr = val.split(",")
  1032. total = newArr.length - 1
  1033. if(total >0){
  1034. return total
  1035. }else{
  1036. return ""
  1037. }
  1038. }
  1039. }
  1040. }
  1041. ,
  1042. created() {
  1043. this.org_id = this.$store.getters.xt_user.org.id
  1044. var nowDate = new Date()
  1045. var nowYear = nowDate.getFullYear()
  1046. var nowMonth = nowDate.getMonth() + 1
  1047. var nowDay = nowDate.getDate()
  1048. this.warehousing_time =
  1049. nowYear +
  1050. '-' +
  1051. (nowMonth < 10 ? '0' + nowMonth : nowMonth) +
  1052. '-' +
  1053. (nowDay < 10 ? '0' + nowDay : nowDay)
  1054. const tempObj = {}
  1055. tempObj['good_type_id'] = 0
  1056. tempObj['good_id'] = 0
  1057. tempObj['number'] = ''
  1058. tempObj['product_date'] = ''
  1059. tempObj['expiry_date'] = ''
  1060. tempObj['warehousing_count'] = ''
  1061. tempObj['price'] = ''
  1062. tempObj['remark'] = ''
  1063. tempObj['dealer'] = ''
  1064. tempObj['manufacturer'] = ''
  1065. tempObj['good_unit'] = ''
  1066. tempObj['good_name'] = ''
  1067. tempObj['specification_name'] = ''
  1068. tempObj['name'] = ''
  1069. tempObj['license_number'] = ''
  1070. tempObj['packing_price']= ''
  1071. tempObj['id']= 0
  1072. tempObj['register_number'] = ''
  1073. tempObj['good_code'] = ''
  1074. tempObj['good_code_cnt'] = ''
  1075. this.recordInfo.recordData.push(tempObj)
  1076. this.GetConfigInfo()
  1077. this.propForm.goodUnit = this.$store.getters.good_unit
  1078. }
  1079. }
  1080. </script>
  1081. <style>
  1082. #oictable ::-webkit-scrollbar {
  1083. height: 15px;
  1084. }
  1085. </style>
  1086. <style rel="stylesheet/css" lang="scss" scoped>
  1087. .information {
  1088. border: 1px #dcdfe6 solid;
  1089. padding: 30px 20px 30px 20px;
  1090. .border {
  1091. border-bottom: 1px #dcdfe6 solid;
  1092. margin: 0px 0 20px 0;
  1093. }
  1094. }
  1095. .edit_separater {
  1096. border-top: 1px solid rgb(233, 233, 233);
  1097. margin-top: 15px;
  1098. margin-bottom: 15px;
  1099. }
  1100. </style>
  1101. <style>
  1102. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  1103. font-size: 12px;
  1104. }
  1105. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  1106. background: #6fb5fa;
  1107. }
  1108. .el-autocomplete-suggestion{
  1109. /* width: 400px !important; */
  1110. width: auto !important;
  1111. }
  1112. </style>