displace_form.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
  4. <div class="main-title">
  5. <div class="title">置换订单信息</div>
  6. </div>
  7. <el-form ref="mainForm" :model="mainForm" label-width="100px" size="small" label-position="left">
  8. <el-row :gutter="20">
  9. <el-col :xs="24" :sm="12" :lg="8">
  10. <el-form-item label="订单号" prop="orderNo">
  11. <div >
  12. <el-input v-model="mainForm.orderNo" placeholder="请输入订单号" disabled>
  13. <el-button slot="append" icon="el-icon-search" @click="openShareDetail" class="choose-order">选择</el-button>
  14. </el-input>
  15. </div>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  19. <el-form-item label="单据日期" prop="orderDate" :rules="{ required: true, message: '单据日期不能为空', trigger: 'blur' }">
  20. <el-date-picker
  21. v-model="mainForm.orderDate"
  22. type="date"
  23. value-format="yyyy-MM-dd"
  24. style="width: 100%;"
  25. placeholder="选择日期">
  26. </el-date-picker>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :sm="12" :lg="8">
  30. <el-form-item label="品类" prop="mainName">
  31. <el-input :value="mainForm.mainName" placeholder="品类" disabled></el-input>
  32. </el-form-item>
  33. </el-col>
  34. <template v-if="mainForm.policyCode">
  35. <el-col :xs="24" :sm="12" :lg="8">
  36. <el-form-item label="销售政策编号" prop="policyCode">
  37. <el-input :value="mainForm.policyCode" placeholder="销售政策编号" disabled></el-input>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :xs="24" :sm="12" :lg="8">
  41. <el-form-item label="销售政策" prop="policyTitle">
  42. <el-input :value="mainForm.policyTitle" placeholder="销售政策" disabled></el-input>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :xs="24" :sm="12" :lg="8">
  46. <el-form-item label="销售政策说明" prop="policyRemark">
  47. <el-input :value="mainForm.policyRemark" placeholder="销售政策说明" disabled></el-input>
  48. </el-form-item>
  49. </el-col>
  50. </template>
  51. <template v-if="mainForm.enginRecordNo">
  52. <el-col :xs="24" :sm="12" :lg="8">
  53. <el-form-item label="工程登录编号" prop="enginRecordNo">
  54. <el-input :value="mainForm.enginRecordNo" placeholder="工程登录编号" disabled></el-input>
  55. </el-form-item>
  56. </el-col>
  57. </template>
  58. <el-col :xs="24" :sm="12" :lg="8">
  59. <el-form-item label="订单类型" prop="orderType">
  60. <el-input :value="$parent.findOrderType(mainForm.orderType)" placeholder="订单类型" disabled></el-input>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :xs="24" :sm="12" :lg="8">
  64. <el-form-item label="业务员" prop="serviceName">
  65. <el-input :value="mainForm.serviceName" placeholder="业务员" disabled></el-input>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :xs="24" :sm="24" :lg="24">
  69. <el-form-item label="备注" prop="remark">
  70. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  71. </el-form-item>
  72. </el-col>
  73. </el-row>
  74. </el-form>
  75. <div class="main-title">
  76. <div class="title">原订单货品信息</div>
  77. </div>
  78. <div class="table" style="margin-top: 20px">
  79. <el-table :data="originGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
  80. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  81. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="160" show-overflow-tooltip></el-table-column>
  82. <el-table-column align="center" label="产品编码" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
  83. <el-table-column align="center" label="产品旧编码" prop="materialOldNumber" min-width="160" show-overflow-tooltip></el-table-column>
  84. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  85. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  86. <el-table-column align="center" label="单位" prop="unit" min-width="160" show-overflow-tooltip></el-table-column>
  87. <el-table-column align="center" label="单价" prop="price" min-width="160" show-overflow-tooltip></el-table-column>
  88. <el-table-column align="center" label="数量" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
  89. <el-table-column align="center" label="订单金额" prop="totalAmount" min-width="100" show-overflow-tooltip></el-table-column>
  90. <el-table-column align="center" label="返利类型" prop="customerWalletName2" min-width="100" show-overflow-tooltip></el-table-column>
  91. <el-table-column align="center" label="返利金额" prop="rebateAmount" min-width="100" show-overflow-tooltip></el-table-column>
  92. <el-table-column align="center" label="格力折扣" prop="discAmount" min-width="100" show-overflow-tooltip></el-table-column>
  93. <el-table-column align="center" label="现金钱包" prop="customerWalletName" min-width="100" show-overflow-tooltip></el-table-column>
  94. <el-table-column align="center" label="实付金额" prop="payAmount" min-width="100" show-overflow-tooltip></el-table-column>
  95. <el-table-column align="center" label="原数量" prop="refundableQty" min-width="100" show-overflow-tooltip></el-table-column>
  96. <el-table-column align="center" label="置换数量" prop="displaceQty" min-width="100" show-overflow-tooltip></el-table-column>
  97. <el-table-column align="center" label="备注" prop="remark" min-width="100" show-overflow-tooltip></el-table-column>
  98. <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip></el-table-column>
  99. </el-table>
  100. </div>
  101. <div class="main-title" v-if="mainForm.orderNo">
  102. <div class="title">置换货品信息</div>
  103. <div v-if="!listItem">
  104. <el-select v-model="warehouseValue" placeholder="请选择发货仓库" size="small" style="margin-right: 10px">
  105. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  106. </el-select>
  107. <el-button type="primary" size="small" icon="el-icon-search" @click="checkStock">检查库存</el-button>
  108. <el-divider direction="vertical"></el-divider>
  109. <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加货品</el-button>
  110. </div>
  111. </div>
  112. <div class="table" style="margin-top: 20px" v-if="mainForm.orderNo">
  113. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
  114. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  115. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="160" show-overflow-tooltip></el-table-column>
  116. <el-table-column align="center" label="产品编码" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
  117. <el-table-column align="center" label="产品旧编码" prop="materialOldNumber" min-width="160" show-overflow-tooltip></el-table-column>
  118. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  119. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  120. <el-table-column align="center" label="单位" prop="unit" min-width="160" show-overflow-tooltip></el-table-column>
  121. <el-table-column align="center" label="单价" prop="price" min-width="160" show-overflow-tooltip></el-table-column>
  122. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  123. <template slot-scope="scope">
  124. <el-input v-model="scope.row.qty" size="small"></el-input>
  125. </template>
  126. </el-table-column>
  127. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  128. <template slot-scope="scope">
  129. {{scope.row.price * scope.row.qty}}
  130. </template>
  131. </el-table-column>
  132. <el-table-column align="center" label="返利类型" prop="customerWalletId2" min-width="160" show-overflow-tooltip>
  133. <template slot-scope="scope">
  134. <el-select v-model="scope.row.customerWalletId2" placeholder="选择返利类型" size="small" clearable @change="changeWallet(scope.$index)">
  135. <el-option
  136. v-for="item in flWalletList"
  137. :key="item.customerWalletId"
  138. :label="item.name"
  139. :value="item.customerWalletId">
  140. </el-option>
  141. </el-select>
  142. </template>
  143. </el-table-column>
  144. <el-table-column align="center" label="使用返利金额" min-width="120" show-overflow-tooltip>
  145. <template slot-scope="scope">
  146. {{(scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100}}
  147. </template>
  148. </el-table-column>
  149. <el-table-column align="center" label="格力折扣" min-width="100" show-overflow-tooltip>
  150. <template slot-scope="scope">
  151. {{scope.row.qty * scope.row.discAmount}}
  152. </template>
  153. </el-table-column>
  154. <el-table-column align="center" label="现金钱包" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  155. <template slot-scope="scope">
  156. <el-select v-model="scope.row.customerWalletId" placeholder="选择现金钱包" size="small" clearable>
  157. <el-option
  158. v-for="item in xjWalletList"
  159. :key="item.customerWalletId"
  160. :label="item.name"
  161. :value="item.customerWalletId">
  162. </el-option>
  163. </el-select>
  164. </template>
  165. </el-table-column>
  166. <el-table-column align="center" label="实付金额" prop="payAmount" min-width="100" show-overflow-tooltip>
  167. <template slot-scope="scope">
  168. {{((scope.row.price * scope.row.qty) * 100 - ((scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100) * 100 - ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) / 100}}
  169. </template>
  170. </el-table-column>
  171. <el-table-column align="center" label="备注" prop="remark" min-width="160">
  172. <template slot-scope="scope">
  173. <el-input v-model="scope.row.remark" size="small"></el-input>
  174. </template>
  175. </el-table-column>
  176. <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip></el-table-column>
  177. <el-table-column align="center" label="总仓库" prop="status1" min-width="100" show-overflow-tooltip v-if="!listItem">
  178. <template slot-scope="scope">
  179. <div>{{ scope.row.status1 | status1Filter }}</div>
  180. </template>
  181. </el-table-column>
  182. <el-table-column align="center" label="仓库状态" prop="status2" min-width="100" show-overflow-tooltip v-if="!listItem">
  183. <template slot-scope="scope">
  184. <div>{{ status2Filter(scope.row) }}</div>
  185. </template>
  186. </el-table-column>
  187. <el-table-column align="center" label="操作" width="100" fixed="right">
  188. <template slot-scope="scope">
  189. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  190. </template>
  191. </el-table-column>
  192. </el-table>
  193. </div>
  194. <div class="page-footer">
  195. <div class="footer" :class="classObj">
  196. <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
  197. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
  198. <el-button slot="reference">关 闭</el-button>
  199. </el-popconfirm>
  200. </div>
  201. </div>
  202. <!-- 订单列表 -->
  203. <el-dialog title="订单列表" :visible.sync="isShowOriginDialog" width="70%" :close-on-click-modal="false">
  204. <el-form v-if="mainForm.examineStatus === ''" ref="screenOriginForm" :model="screenOriginForm" label-width="80px" size="small">
  205. <el-row :gutter="20">
  206. <el-col :xs="24" :sm="12" :lg="8">
  207. <el-form-item label="原订单号"
  208. prop="orderNo"
  209. :rules="{ required: true, message: '原订单号不能为空', trigger: 'blur' }"
  210. >
  211. <el-input v-model="screenOriginForm.orderNo" placeholder="原订单号"></el-input>
  212. </el-form-item>
  213. </el-col>
  214. <el-col :xs="24" :sm="12" :lg="6" class="tr">
  215. <el-form-item label="">
  216. <el-button size="small" type="primary" @click="submitScreenOriginForm">搜索</el-button>
  217. </el-form-item>
  218. </el-col>
  219. </el-row>
  220. </el-form>
  221. <div class="table" style="margin: 10px 0 20px;">
  222. <el-table
  223. ref="originOrderTable"
  224. v-loading="dialogTable_listLoading"
  225. :data="dialogTable_dataList"
  226. element-loading-text="Loading"
  227. tooltip-effect="dark"
  228. style="width: 100%"
  229. border
  230. max-height="270">
  231. <el-table-column type="selection" width="55"></el-table-column>
  232. <el-table-column align="center" prop="orderType" label="订单类型" show-overflow-tooltip>
  233. <template slot-scope="scope">
  234. {{ $parent.findOrderType(dialogTable_data.orderType) }}
  235. </template>
  236. </el-table-column>
  237. <el-table-column align="center" prop="saleTypeName" label="销售类型" show-overflow-tooltip></el-table-column>
  238. <el-table-column align="center" prop="materialName" label="产品名称" show-overflow-tooltip></el-table-column>
  239. <el-table-column align="center" prop="specification" label="规格型号" show-overflow-tooltip></el-table-column>
  240. <el-table-column align="center" prop="unit" label="单位" show-overflow-tooltip></el-table-column>
  241. <el-table-column align="center" prop="qty" label="数量" show-overflow-tooltip></el-table-column>
  242. <el-table-column align="center" prop="refundableQty" label="可退单置换数" show-overflow-tooltip></el-table-column>
  243. <el-table-column align="center" prop="displaceQty" label="退订置换数" show-overflow-tooltip>
  244. <template slot-scope="scope">
  245. <el-input v-model="scope.row.displaceQty" size="small"></el-input>
  246. </template>
  247. </el-table-column>
  248. </el-table>
  249. </div>
  250. <div slot="footer" class="dialog-footer">
  251. <el-button @click="isShowOriginDialog = false">关 闭</el-button>
  252. <el-button @click="chooseDetail">提 交</el-button>
  253. </div>
  254. </el-dialog>
  255. <el-dialog title="添加产品" :visible.sync="isShowDialog" width="80%">
  256. <el-form ref="screenForm" :model="screenForm" size="small" label-position="left">
  257. <el-row :gutter="20">
  258. <el-col :xs="12" :sm="6" :lg="6">
  259. <el-form-item prop="type">
  260. <el-select v-model="mainForm.mainId" placeholder="选择品类" style="width: 100%" disabled>
  261. <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
  262. </el-select>
  263. </el-form-item>
  264. </el-col>
  265. <el-col :xs="12" :sm="6" :lg="6">
  266. <el-form-item prop="salesType">
  267. <el-select v-model="screenForm.salesType" placeholder="选择销售类型" style="width: 100%" clearable>
  268. <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id"></el-option>
  269. </el-select>
  270. </el-form-item>
  271. </el-col>
  272. <el-col :xs="12" :sm="6" :lg="6">
  273. <el-form-item prop="proNum">
  274. <el-input v-model="screenForm.proNum" placeholder="请输入产品编码"></el-input>
  275. </el-form-item>
  276. </el-col>
  277. <el-col :xs="12" :sm="6" :lg="6">
  278. <el-form-item prop="proName">
  279. <el-input v-model="screenForm.proName" placeholder="请输入产品名称"></el-input>
  280. </el-form-item>
  281. </el-col>
  282. <el-col :xs="12" :sm="6" :lg="6">
  283. <el-form-item prop="proModel">
  284. <el-input v-model="screenForm.proModel" placeholder="请输入产品型号"></el-input>
  285. </el-form-item>
  286. </el-col>
  287. <el-col :xs="12" :sm="6" :lg="6">
  288. <el-form-item prop="price1" style="display: flex">
  289. <el-input v-model="screenForm.price1" placeholder="请输入价格" style="width: 46%"></el-input>
  290. <span> - </span>
  291. <el-input v-model="screenForm.price2" placeholder="请输入价格" style="width: 46%"></el-input>
  292. </el-form-item>
  293. </el-col>
  294. <el-col :xs="12" :sm="12" :lg="12" class="tr">
  295. <el-form-item label="">
  296. <el-button size="small" @click="resetScreenForm">清空</el-button>
  297. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  298. </el-form-item>
  299. </el-col>
  300. </el-row>
  301. </el-form>
  302. <div class="tables">
  303. <div class="table">
  304. <el-table :data="leftGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="leftSelectionChange">
  305. <el-table-column align="center" type="selection" width="55" :selectable='checkboxSelect'></el-table-column>
  306. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  307. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  308. <el-table-column align="center" label="产品型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  309. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip></el-table-column>
  310. </el-table>
  311. <div class="pagination clearfix" style="margin-top: 10px">
  312. <div class="fr">
  313. <el-pagination
  314. @current-change="handleTableCurrentChange"
  315. :current-page="currentPage"
  316. :page-size="10"
  317. background
  318. layout="prev, pager, next"
  319. :total="listTotal">
  320. </el-pagination>
  321. </div>
  322. </div>
  323. </div>
  324. <div class="buttons">
  325. <el-button size="small" type="primary" @click="addAllGoods">全部添加</el-button>
  326. <el-button size="small" type="primary" @click="addGoods">添&emsp;加</el-button>
  327. <el-button size="small" type="danger" @click="deleteGoods">删&emsp;除</el-button>
  328. <el-button size="small" type="danger" @click="deleteAllGoods">全部删除</el-button>
  329. </div>
  330. <div class="table">
  331. <el-table :data="rightGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="rightSelectionChange">
  332. <el-table-column align="center" type="selection" width="55"></el-table-column>
  333. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  334. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  335. <el-table-column align="center" label="产品型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  336. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip></el-table-column>
  337. </el-table>
  338. </div>
  339. </div>
  340. <span slot="footer" class="dialog-footer">
  341. <el-button @click="closeDialog">取 消</el-button>
  342. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  343. </span>
  344. </el-dialog>
  345. </div>
  346. </template>
  347. <script>
  348. import {getDetail, queryRefDetail, addData, editData} from "@/api/supply/displace";
  349. import {checkStock, getWalletList, getWarehouseList} from "@/api/supply/engin";
  350. import {getDictList, getTypeList} from "@/api/common";
  351. import {getGoodsList} from "@/api/supply/retail";
  352. export default {
  353. name: 'DisplaceForm',
  354. componentName: 'DisplaceForm',
  355. props: ['listItem'],
  356. filters: {
  357. status1Filter(val) {
  358. if (val === '' || val === null || val === undefined) return '未检查';
  359. else if (val === 0) return '无货';
  360. else if (val > 0 && val <= 30) return val;
  361. else if (val > 30 && val <= 1000) return '有货';
  362. else if (val > 1000) return '充足';
  363. },
  364. },
  365. data() {
  366. return {
  367. editId: '',
  368. detailData: {},
  369. mainForm: {
  370. displaceOrderId: '',
  371. orderType: '',
  372. orderNo: '',
  373. orderDate: '',
  374. mainId: '',
  375. mainName: '',
  376. enginRecordNo: '',
  377. projectNo: '',
  378. projectName: '',
  379. useUnit: '',
  380. installAddress: '',
  381. policyId: '',
  382. policyCode: '',
  383. policyTitle: '',
  384. policyRemark: '',
  385. serviceId: '',
  386. serviceName: '',
  387. takeDeposit: '',
  388. remark: '',
  389. examineStatus: ''
  390. },
  391. isShowOriginDialog: false,
  392. isShowDialog: false,
  393. dialogTable_data: null, // 列表订单数据
  394. dialogTable_dataList: [],
  395. dialogTable_listLoading: false, // 列表加载loading
  396. screenOriginForm: {
  397. orderNo: ''
  398. },
  399. screenForm: {
  400. type: '',
  401. salesType: '',
  402. proNum: '',
  403. proName: '',
  404. proModel: '',
  405. price1: '',
  406. price2: '',
  407. },
  408. currentPage: 1,
  409. listTotal: 0,
  410. salesTypeList: [],
  411. typeList: [],
  412. goodsList: [],
  413. originGoodsList: [],
  414. warehouseList: [],
  415. warehouseValue: '',
  416. leftGoodsList: [],
  417. rightGoodsList: [],
  418. leftSelection: [],
  419. rightSelection: [],
  420. xjWalletList: [],
  421. flWalletList: []
  422. }
  423. },
  424. computed: {
  425. sidebar() {
  426. return this.$store.state.app.sidebar
  427. },
  428. classObj() {
  429. return {
  430. hideSidebar: !this.sidebar.opened,
  431. openSidebar: this.sidebar.opened
  432. }
  433. },
  434. },
  435. created() {
  436. this.getDictList();
  437. this.getWalletList();
  438. this.getSalesTypeList();
  439. this.getWarehouseList();
  440. if(this.listItem) {
  441. this.editId = this.listItem.displaceOrderId;
  442. this.getDetail();
  443. } else {
  444. this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
  445. this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
  446. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  447. this.mainForm.createDate = this.getDate();
  448. }
  449. },
  450. methods: {
  451. // 返回列表
  452. goBack() {
  453. this.$emit('backListFormDetail');
  454. },
  455. // 获取详情
  456. getDetail() {
  457. getDetail({id: this.editId}).then(res => {
  458. const data = res.data;
  459. this.mainForm.displaceOrderId = data.displaceOrderId
  460. this.mainForm.orderType = data.orderType
  461. this.mainForm.orderNo = data.orderNo
  462. this.mainForm.orderDate = data.orderDate
  463. this.mainForm.mainId = data.mainId
  464. this.mainForm.mainName = data.mainName
  465. this.mainForm.enginRecordNo = data.enginRecordNo
  466. this.mainForm.projectNo = data.projectNo
  467. this.mainForm.projectName = data.projectName
  468. this.mainForm.useUnit = data.useUnit
  469. this.mainForm.installAddress = data.installAddress
  470. this.mainForm.policyId = data.policyId
  471. this.mainForm.policyCode = data.policyCode
  472. this.mainForm.policyTitle = data.policyTitle
  473. this.mainForm.policyRemark = data.policyRemark
  474. this.mainForm.serviceId = data.serviceId
  475. this.mainForm.serviceName = data.serviceName
  476. this.mainForm.takeDeposit = data.takeDeposit
  477. this.mainForm.examineStatus = data.examineStatus
  478. this.originGoodsList = data.originItems
  479. this.goodsList = data.items
  480. })
  481. },
  482. // 原订单列表 - 打开弹窗
  483. openShareDetail() {
  484. this.isShowOriginDialog = true;
  485. if (this.mainForm.examineStatus && this.originGoodsList.length > 0) {
  486. this.screenOriginForm.orderNo = this.mainForm.orderNo
  487. this.queryRefDetail()
  488. }
  489. },
  490. submitScreenOriginForm() {
  491. this.$refs['screenOriginForm'].validate((valid) => {
  492. if (valid) {
  493. this.queryRefDetail()
  494. }
  495. })
  496. },
  497. queryRefDetail() {
  498. this.dialogTable_listLoading = true
  499. queryRefDetail({
  500. originOrderNo: this.screenOriginForm.orderNo
  501. }).then(res => {
  502. this.dialogTable_data = res.data;
  503. this.dialogTable_dataList = this.dialogTable_data.originItems
  504. if (this.mainForm.displaceOrderId) {
  505. this.originAfterHandle(this.dialogTable_dataList)
  506. }
  507. this.dialogTable_listLoading = false;
  508. }).catch(() => {
  509. this.dialogTable_listLoading = false;
  510. })
  511. },
  512. originAfterHandle() {
  513. const data = this.dialogTable_dataList
  514. // 历史选中的置换数回显
  515. this.$nextTick(() => {
  516. for (let i = 0; i < data.length; i++) {
  517. this.originGoodsList.forEach(goods => {
  518. if (goods.materialId === data[i].materialId) {
  519. data[i].displaceQty = goods.displaceQty
  520. this.$refs['originOrderTable'].toggleRowSelection(data[i], true)
  521. }
  522. })
  523. }
  524. })
  525. },
  526. chooseDetail() {
  527. const tableData = this.$refs['originOrderTable'].selection
  528. if (!tableData || tableData.length === 0) {
  529. return this.$errorMsg('请选择订单明细')
  530. }
  531. for (let i = 0; i < tableData.length; i++) {
  532. if (!tableData[i].displaceQty || tableData[i].displaceQty <= 0) {
  533. return this.$errorMsg(tableData[i].materialName + ':置换数量不能少于0')
  534. }
  535. if (tableData[i].displaceQty > tableData[i].refundableQty) {
  536. return this.$errorMsg(tableData[i].materialName + ':置换数量不能大于可退单置换数 ')
  537. }
  538. }
  539. this.originGoodsList = tableData
  540. this.mainForm.orderType = this.dialogTable_data.orderType
  541. this.mainForm.orderNo = this.dialogTable_data.orderNo
  542. this.mainForm.mainId = this.dialogTable_data.mainId
  543. this.mainForm.mainName = this.dialogTable_data.mainName
  544. this.mainForm.enginRecordNo = this.dialogTable_data.enginRecordNo
  545. this.mainForm.projectNo = this.dialogTable_data.projectNo
  546. this.mainForm.projectName = this.dialogTable_data.projectName
  547. this.mainForm.useUnit = this.dialogTable_data.useUnit
  548. this.mainForm.installAddress = this.dialogTable_data.installAddress
  549. this.mainForm.policyId = this.dialogTable_data.policyId
  550. this.mainForm.policyCode = this.dialogTable_data.policyCode
  551. this.mainForm.policyTitle = this.dialogTable_data.policyTitle
  552. this.mainForm.policyRemark = this.dialogTable_data.policyRemark
  553. this.mainForm.serviceId = this.dialogTable_data.serviceId
  554. this.mainForm.serviceName = this.dialogTable_data.serviceName
  555. this.mainForm.takeDeposit = this.dialogTable_data.takeDeposit
  556. this.isShowOriginDialog = false
  557. },
  558. clickSubmitForm() {
  559. this.$refs.mainForm.validate((valid) => {
  560. if (valid) {
  561. for(let i=0; i<this.goodsList.length; i++) {
  562. if (!this.goodsList[i].qty || this.goodsList[i].qty <= 0) {
  563. this.$errorMsg(this.goodsList[i].materialName + '数量不能小于0');
  564. return;
  565. }
  566. if(!this.goodsList[i].customerWalletId) {
  567. this.$errorMsg('请选择现金钱包');
  568. return;
  569. }
  570. }
  571. let params = {
  572. orderDate: this.mainForm.orderDate + ' 00:00:00',
  573. orderNo: this.mainForm.orderNo,
  574. remark: this.mainForm.remark,
  575. originItems: this.originGoodsList,
  576. items: this.goodsList
  577. }
  578. if(this.listItem) {
  579. params.displaceOrderId = this.editId;
  580. editData(params).then(res => {
  581. this.$successMsg('编辑成功');
  582. this.goBack();
  583. this.$parent.getList();
  584. })
  585. }else {
  586. addData(params).then(res => {
  587. this.$successMsg('添加成功');
  588. this.goBack();
  589. this.$parent.getList();
  590. })
  591. }
  592. }
  593. })
  594. },
  595. // 获取钱包列表
  596. getWalletList() {
  597. getWalletList({
  598. customerId: JSON.parse(localStorage.getItem("supply_user")).customerId,
  599. type: 'COMMONLY'
  600. }).then(res => {
  601. this.xjWalletList = res.data;
  602. })
  603. getWalletList({
  604. customerId: JSON.parse(localStorage.getItem("supply_user")).customerId,
  605. type: 'REBATE'
  606. }).then(res => {
  607. this.flWalletList = res.data;
  608. })
  609. },
  610. // 获取产品大类列表
  611. getDictList() {
  612. getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
  613. this.typeList = res.data;
  614. })
  615. },
  616. // 获取销售类型列表
  617. getSalesTypeList() {
  618. getTypeList({
  619. pageNum: 1,
  620. pageSize: -1
  621. }).then((res) => {
  622. this.salesTypeList = res.data.records;
  623. })
  624. },
  625. // 获取仓库列表
  626. getWarehouseList() {
  627. getWarehouseList({
  628. pageNum: 1,
  629. pageSize: -1
  630. }).then((res) => {
  631. this.warehouseList = res.data.records;
  632. })
  633. },
  634. getDate() {
  635. var date = new Date();
  636. var seperator1 = "-";
  637. var year = date.getFullYear();
  638. var month = date.getMonth() + 1;
  639. var strDate = date.getDate();
  640. if (month >= 1 && month <= 9) {
  641. month = "0" + month;
  642. }
  643. if (strDate >= 0 && strDate <= 9) {
  644. strDate = "0" + strDate;
  645. }
  646. return year + seperator1 + month + seperator1 + strDate;
  647. },
  648. // 检查库存
  649. checkStock() {
  650. if(!this.warehouseValue) {
  651. return this.$errorMsg('请选择仓库');
  652. }
  653. if(!this.goodsList) {
  654. return this.$errorMsg('请添加货品');
  655. }
  656. let ids = [];
  657. this.goodsList.forEach(item => {
  658. ids.push(item.materialId);
  659. })
  660. checkStock({
  661. correspondId: this.warehouseValue,
  662. materialId: ids.join(',')
  663. }).then(res => {
  664. if(res.data) {
  665. this.goodsList.forEach((item, index) => {
  666. item.status1 = res.data[index].allStockNum;
  667. item.status2 = res.data[index].stockNum;
  668. })
  669. }
  670. })
  671. },
  672. // 点击 选择商品
  673. openDialog() {
  674. this.getSalesTypeList();
  675. this.getGoodsList();
  676. this.isShowDialog = true;
  677. },
  678. // 关闭 弹窗
  679. closeDialog() {
  680. this.isShowDialog = false;
  681. },
  682. // 左侧列表选择
  683. leftSelectionChange(val) {
  684. this.leftSelection = val;
  685. },
  686. // 右侧列表选择
  687. rightSelectionChange(val) {
  688. this.rightSelection = val;
  689. },
  690. // 数组去重
  691. delRepeat(arr1, arr2) {
  692. let allArr = arr1.concat(arr2); // 两个数组对象合并
  693. let newArr = []; // 存放去重后数据的新数组
  694. for(let i=0; i<allArr.length; i++){ // 循环allArr数组对象的内容
  695. let flag = true; // 建立标记,判断数据是否重复,true为不重复
  696. for(let j=0; j<newArr.length; j++){ // 循环新数组的内容
  697. if(allArr[i].materialId == newArr[j].materialId){ // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  698. flag = false;
  699. }
  700. }
  701. if(flag){ // 判断是否重复
  702. newArr.push(allArr[i]); // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  703. }
  704. }
  705. return newArr;
  706. },
  707. // 全部添加
  708. addAllGoods() {
  709. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList);
  710. },
  711. // 添加
  712. addGoods() {
  713. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList);
  714. },
  715. // 删除
  716. deleteGoods() {
  717. let rightGoodsList = this.rightGoodsList;
  718. let rightSelection = this.rightSelection;
  719. for(let i = 0; i < rightGoodsList.length; i++) {
  720. for(let j = 0; j < rightSelection.length; j++) {
  721. if(rightSelection[j].materialId == rightGoodsList[i].materialId){
  722. this.rightGoodsList.splice(i, 1);
  723. }
  724. }
  725. }
  726. },
  727. // 全部删除
  728. deleteAllGoods() {
  729. this.rightGoodsList = [];
  730. },
  731. // 确定 添加产品
  732. submitAddGoods() {
  733. this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList);
  734. this.isShowDialog = false;
  735. this.leftGoodsList = [];
  736. this.rightGoodsList = [];
  737. },
  738. // 查询重复值并禁选
  739. checkboxSelect(row, rowIndex) {
  740. if (row.selected) {
  741. return false // 禁用
  742. }else{
  743. return true // 不禁用
  744. }
  745. },
  746. // 删除产品
  747. deleteItem(index) {
  748. this.goodsList.splice(index, 1);
  749. },
  750. // 提交筛选表单
  751. submitScreenForm() {
  752. this.currentPage = 1;
  753. this.getGoodsList();
  754. },
  755. // 重置筛选表单
  756. resetScreenForm() {
  757. this.$refs.screenForm.resetFields();
  758. this.currentPage = 1;
  759. this.getGoodsList();
  760. },
  761. // 更改列表当前页
  762. handleTableCurrentChange(val) {
  763. this.currentPage = val;
  764. this.getGoodsList();
  765. },
  766. // 修改返利钱包
  767. changeWallet(index) {
  768. if(this.goodsList[index].customerWalletId2) {
  769. let obj = this.flWalletList.find(o => o.customerWalletId == this.goodsList[index].customerWalletId2);
  770. this.goodsList[index].rebateRate = obj.rebateRate;
  771. }else {
  772. this.goodsList[index].rebateRate = '';
  773. }
  774. },
  775. status2Filter(item) {
  776. if (item.status2 === '' || item.status2 === null || item.status2 === undefined) return '未检查';
  777. if ( item.status2 <= 0 ) {
  778. return '无货'
  779. }else if(item.status2 >= 1 && item.status2 <= 30){
  780. return item.status2
  781. }else if(item.status2 >=31 && item.status2 <= 1000 ){
  782. return '有货'
  783. }else{
  784. return '充足'
  785. }
  786. },
  787. // 获取商品列表
  788. getGoodsList() {
  789. getGoodsList({
  790. pageNum: this.currentPage,
  791. pageSize: 10,
  792. mainId: this.mainForm.mainId,
  793. saleId: this.screenForm.salesType,
  794. materialCode: this.screenForm.proNum,
  795. materialName: this.screenForm.proName,
  796. specification: this.screenForm.proModel,
  797. price1: this.screenForm.price1,
  798. price2: this.screenForm.price2,
  799. }).then(res => {
  800. let oldGoodsList = this.goodsList;
  801. let newGoodsList = res.data.records;
  802. for(let i = 0; i < oldGoodsList.length; i++) {
  803. let oldItem = oldGoodsList[i]
  804. for(let j = 0; j < newGoodsList.length; j++) {
  805. let newItem = newGoodsList[j]
  806. if(newItem.materialId === oldItem.materialId){
  807. newGoodsList[j].selected = true;
  808. break;
  809. }
  810. }
  811. }
  812. res.data.records.forEach(item => {
  813. item.materialName = item.name;
  814. item.materialCode = item.number;
  815. item.saleTypeName = item.saleName;
  816. item.unit = item.baseUnit;
  817. item.price = item.batchPrice;
  818. item.tax = item.taxRate;
  819. item.isDirectTransfer = false;
  820. item.directTransferQty = '';
  821. item.status1 = '';
  822. item.status2 = '';
  823. item.rebateAmount = '';
  824. item.rebateRate = '';
  825. item.productPriceId = item.id;
  826. });
  827. this.leftGoodsList = res.data.records;
  828. this.listTotal = res.data.total;
  829. })
  830. },
  831. }
  832. }
  833. </script>
  834. <style scoped lang="scss">
  835. .detail-container {
  836. width: 100%;
  837. height: 100%;
  838. }
  839. .main-title {
  840. display: flex;
  841. justify-content: space-between;
  842. align-items: center;
  843. margin-top: 20px;
  844. height: 60px;
  845. border-bottom: 1px solid #DCDFE6;
  846. margin-bottom: 20px;
  847. .title {
  848. font-size: 16px;
  849. font-weight: 600;
  850. padding-left: 10px;
  851. }
  852. }
  853. .tables {
  854. display: flex;
  855. margin-top: 10px;
  856. .table {
  857. width: 45%;
  858. }
  859. .buttons {
  860. display: flex;
  861. flex-direction: column;
  862. justify-content: center;
  863. align-items: center;
  864. padding: 0 10px;
  865. button {
  866. margin: 0;
  867. margin-top: 10px;
  868. }
  869. }
  870. }
  871. .choose-order {
  872. }
  873. </style>