commerce_form.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  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" :rules="mainFormRules" label-width="110px" size="small" label-position="right">
  8. <el-row :gutter="20">
  9. <el-col :xs="24" :sm="12" :lg="8">
  10. <el-form-item label="工程订单" prop="orderNum">
  11. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  15. <el-form-item label="单据日期" prop="orderDate">
  16. <el-date-picker
  17. v-model="mainForm.orderDate"
  18. disabled
  19. type="date"
  20. value-format="yyyy-MM-dd"
  21. style="width: 100%;"
  22. placeholder="系统自动生成">
  23. </el-date-picker>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :xs="24" :sm="12" :lg="8">
  27. <el-form-item label="业务员" prop="salesMan">
  28. <el-select v-model="mainForm.salesMan" placeholder="选择业务员" size="small" filterable clearable style="width: 100%">
  29. <el-option
  30. v-for="item in salesmanList"
  31. :key="item.adminUserId"
  32. :label="item.nickName"
  33. :value="item.adminUserId">
  34. </el-option>
  35. </el-select>
  36. </el-form-item>
  37. </el-col>
  38. <!-- <el-col :xs="24" :sm="12" :lg="8">
  39. <el-form-item label="产品大类" prop="type">
  40. <el-select v-model="mainForm.type" placeholder="选择产品大类" style="width: 100%" disabled>
  41. <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
  42. </el-select>
  43. </el-form-item>
  44. </el-col> -->
  45. </el-row>
  46. <el-row :gutter="20">
  47. <el-col :xs="24" :sm="12" :lg="8">
  48. <el-form-item label="经销商编码" prop="jxsNum">
  49. <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码" disabled></el-input>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :xs="24" :sm="12" :lg="16">
  53. <el-form-item label="经销商名称" prop="jxsName">
  54. <el-input v-model="mainForm.jxsName" placeholder="请输入经销商名称" disabled></el-input>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :xs="24" :sm="12" :lg="8">
  58. <el-form-item label="工程信息单号" prop="enginNum">
  59. <div style="display: flex;">
  60. <el-input v-model="mainForm.enginNum" placeholder="请引用工程登录" disabled></el-input>
  61. <el-button style="margin-left: 10px;" @click="openShareDetail">引用</el-button>
  62. </div>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :xs="24" :sm="12" :lg="8">
  66. <el-form-item label="项目类别" prop="enginName">
  67. <el-input v-model="mainForm.enginName" placeholder="请输入项目类别" disabled></el-input>
  68. </el-form-item>
  69. </el-col>
  70. <el-col :xs="24" :sm="12" :lg="8">
  71. <el-form-item label="行业类别" prop="loginType">
  72. <el-input v-model="mainForm.loginType" placeholder="请输入行业类别" disabled></el-input>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :xs="24" :sm="12" :lg="8">
  76. <el-form-item label="跨区厂编号" prop="factoryNum">
  77. <el-input v-model="mainForm.factoryNum" placeholder="请输入跨区厂编号"></el-input>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :xs="24" :sm="12" :lg="8">
  81. <el-form-item label="使用单位" prop="company">
  82. <el-input v-model="mainForm.company" placeholder="请输入使用单位" disabled></el-input>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :xs="24" :sm="12" :lg="8">
  86. <el-form-item label="工程编号" prop="enginNum">
  87. <el-input v-model="mainForm.enginNum" placeholder="请输入工程编号"></el-input>
  88. </el-form-item>
  89. </el-col>
  90. <el-col :xs="24" :sm="12" :lg="8">
  91. <el-form-item label="联系人" prop="contactMan">
  92. <el-input v-model="mainForm.contactMan" placeholder="请输入联系人" disabled></el-input>
  93. </el-form-item>
  94. </el-col>
  95. <el-col :xs="24" :sm="12" :lg="8">
  96. <el-form-item label="固定电话" prop="tel">
  97. <el-input v-model="mainForm.tel" placeholder="请输入固定电话" disabled></el-input>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :xs="24" :sm="12" :lg="8">
  101. <el-form-item label="移动电话" prop="phone">
  102. <el-input v-model="mainForm.phone" placeholder="请输入移动电话" disabled></el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :xs="24" :sm="24" :lg="24">
  106. <el-form-item label="安装地址" prop="address">
  107. <el-input v-model="mainForm.address" placeholder="请输入安装地址" disabled></el-input>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :xs="24" :sm="24" :lg="24">
  111. <el-form-item label="格力内部备注" prop="greeRemark">
  112. <el-input v-model="mainForm.greeRemark" placeholder="请输入格力内部备注"></el-input>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :xs="24" :sm="24" :lg="24">
  116. <el-form-item label="格力回复" prop="greeReply">
  117. <el-input v-model="mainForm.greeReply" placeholder="请输入格力回复"></el-input>
  118. </el-form-item>
  119. </el-col>
  120. <el-col :xs="24" :sm="24" :lg="24">
  121. <el-form-item label="备注" prop="remark">
  122. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :xs="24" :sm="12" :lg="8">
  126. <el-form-item label="制单人" prop="createMan">
  127. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled></el-input>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  131. <el-form-item label="制单日期" prop="createDate">
  132. <el-date-picker
  133. v-model="mainForm.createDate"
  134. disabled
  135. type="date"
  136. value-format="yyyy-MM-dd"
  137. style="width: 100%;"
  138. placeholder="选择日期">
  139. </el-date-picker>
  140. </el-form-item>
  141. </el-col>
  142. <el-col :xs="24" :sm="12" :lg="8">
  143. <el-form-item label="文件编号" prop="fileNum">
  144. <el-input v-model="mainForm.fileNum" placeholder="请输入文件编号"></el-input>
  145. </el-form-item>
  146. </el-col>
  147. </el-row>
  148. </el-form>
  149. <div class="main-title">
  150. <div class="title">货品信息</div>
  151. <div>
  152. <el-select v-model="warehouseValue" placeholder="请选择发货仓库" size="small" style="margin-right: 10px">
  153. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  154. </el-select>
  155. <el-button type="primary" size="small" icon="el-icon-search" @click="checkStock">检查库存</el-button>
  156. </div>
  157. </div>
  158. <div class="table" style="margin-top: 20px">
  159. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400" @selection-change="handleSelectionChange">
  160. <el-table-column align="center" type="selection" width="55"></el-table-column>
  161. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  162. <el-table-column align="center" label="引用记录" prop="useRefCount" min-width="160" show-overflow-tooltip></el-table-column>
  163. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="120" show-overflow-tooltip></el-table-column>
  164. <el-table-column align="center" label="物料编码" prop="materialNumber" min-width="120" show-overflow-tooltip></el-table-column>
  165. <el-table-column align="center" label="产品编码" prop="materialOldNumber" min-width="120" show-overflow-tooltip></el-table-column>
  166. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  167. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
  168. <template slot-scope="scope">
  169. <el-input v-model="scope.row.specification" size="small" v-if="listItem"></el-input>
  170. <div v-else>{{scope.row.specification}}</div>
  171. </template>
  172. </el-table-column>
  173. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  174. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  175. <template slot-scope="scope">
  176. <el-input v-model="scope.row.price" size="small" type="number" v-if="!isDealer"></el-input>
  177. <div v-else>{{scope.row.price}}</div>
  178. </template>
  179. </el-table-column>
  180. <el-table-column align="center" label="工程信息数量" prop="enginNum" min-width="120" show-overflow-tooltip></el-table-column>
  181. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  182. <template slot-scope="scope">
  183. <el-input v-model="scope.row.qty" size="small"></el-input>
  184. </template>
  185. </el-table-column>
  186. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  187. <template slot-scope="scope">
  188. {{scope.row.price * scope.row.qty}}
  189. </template>
  190. </el-table-column>
  191. <el-table-column align="center" label="返利钱包" prop="customerWalletId2" min-width="160" show-overflow-tooltip>
  192. <template slot-scope="scope">
  193. <el-select v-model="scope.row.customerWalletId2" placeholder="选择返利类型" size="small" clearable @change="changeFlWallet(scope.$index)">
  194. <el-option
  195. v-for="item in scope.row.rebateWallets"
  196. :key="item.customerWalletId"
  197. :label="item.customerWalletName"
  198. :value="item.customerWalletId">
  199. </el-option>
  200. </el-select>
  201. </template>
  202. </el-table-column>
  203. <el-table-column align="center" label="返利金额" min-width="100" show-overflow-tooltip>
  204. <template slot-scope="scope">
  205. {{(scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100}}
  206. </template>
  207. </el-table-column>
  208. <el-table-column align="center" label="格力折扣" min-width="100" show-overflow-tooltip>
  209. <template slot-scope="scope">
  210. {{scope.row.qty * scope.row.discAmount}}
  211. </template>
  212. </el-table-column>
  213. <el-table-column align="center" label="现金钱包" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  214. <template slot-scope="scope">
  215. <el-select v-model="scope.row.customerWalletId" placeholder="选择现金钱包" size="small" clearable @change="changeXjWallet(scope.$index)">
  216. <el-option
  217. v-for="item in scope.row.wallets"
  218. :key="item.customerWalletId"
  219. :label="item.customerWalletName"
  220. :value="item.customerWalletId">
  221. </el-option>
  222. </el-select>
  223. </template>
  224. </el-table-column>
  225. <el-table-column align="center" label="实付金额" prop="qty" min-width="100" show-overflow-tooltip>
  226. <template slot-scope="scope">
  227. {{((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}}
  228. </template>
  229. </el-table-column>
  230. <el-table-column align="center" label="是否直调" prop="isDirectTransfer" min-width="100">
  231. <template slot-scope="scope">
  232. <el-checkbox v-model="scope.row.isDirectTransfer"></el-checkbox>
  233. </template>
  234. </el-table-column>
  235. <el-table-column align="center" label="直调数量" prop="directTransferQty" min-width="100"></el-table-column>
  236. <el-table-column align="center" label="已发货数量" prop="hasSendQty" min-width="100" show-overflow-tooltip></el-table-column>
  237. <el-table-column align="center" label="已退数量" prop="retiredQty" min-width="100" show-overflow-tooltip></el-table-column>
  238. <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip>
  239. <template slot-scope="scope">
  240. <el-input v-model="scope.row.remark" size="small"></el-input>
  241. </template>
  242. </el-table-column>
  243. <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip></el-table-column>
  244. <!-- <el-table-column align="center" label="总仓库" prop="status1" min-width="100" show-overflow-tooltip>
  245. <template slot-scope="scope">
  246. <div>{{ scope.row.status1 | status1Filter }}</div>
  247. </template>
  248. </el-table-column> -->
  249. <el-table-column align="center" label="仓库状态" prop="status2" min-width="100" show-overflow-tooltip>
  250. <template slot-scope="scope">
  251. <div>{{ status2Filter(scope.row) }}</div>
  252. </template>
  253. </el-table-column>
  254. <!-- <el-table-column align="center" label="业务员" prop="serviceId" min-width="160" show-overflow-tooltip>
  255. <template slot-scope="scope">
  256. <el-select v-model="scope.row.serviceId" placeholder="选择业务员" size="small" clearable>
  257. <el-option
  258. v-for="item in salesmanList"
  259. :key="item.adminUserId"
  260. :label="item.nickName"
  261. :value="item.adminUserId">
  262. </el-option>
  263. </el-select>
  264. </template>
  265. </el-table-column> -->
  266. <el-table-column align="center" label="操作" width="100" fixed="right">
  267. <template slot-scope="scope">
  268. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  269. </template>
  270. </el-table-column>
  271. </el-table>
  272. </div>
  273. <div class="page-footer">
  274. <div class="footer">
  275. <el-button type="primary" @click="clickSubmitForm(1)">保 存</el-button>
  276. <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>
  277. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
  278. <el-button slot="reference">关 闭</el-button>
  279. </el-popconfirm>
  280. </div>
  281. </div>
  282. <!-- 工程登录列表 -->
  283. <el-dialog title="工程登录列表" :visible.sync="isShowDialog" width="70%" :close-on-click-modal="false">
  284. <el-form ref="screenForm" :model="screenForm" label-width="0" size="small" label-position="left">
  285. <el-row :gutter="20">
  286. <el-col :xs="24" :sm="12" :lg="6">
  287. <el-form-item prop="enginNum">
  288. <el-input v-model="screenForm.enginNum" placeholder="工程信息单"></el-input>
  289. </el-form-item>
  290. </el-col>
  291. <el-col :xs="24" :sm="12" :lg="6">
  292. <el-form-item prop="enginName">
  293. <el-input v-model="screenForm.enginName" placeholder="工程项目"></el-input>
  294. </el-form-item>
  295. </el-col>
  296. <el-col :xs="24" :sm="12" :lg="6">
  297. <el-form-item prop="company">
  298. <el-input v-model="screenForm.company" placeholder="使用单位"></el-input>
  299. </el-form-item>
  300. </el-col>
  301. <el-col :xs="24" :sm="12" :lg="6" class="tr">
  302. <el-form-item label="">
  303. <el-button size="small" @click="resetScreenForm">清空</el-button>
  304. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  305. </el-form-item>
  306. </el-col>
  307. </el-row>
  308. </el-form>
  309. <div class="table" style="margin: 10px 0 20px;">
  310. <el-table
  311. v-loading="dialogTable_listLoading"
  312. :data="dialogTable_dataList"
  313. element-loading-text="Loading"
  314. tooltip-effect="dark"
  315. style="width: 100%"
  316. max-height="270">
  317. <el-table-column align="center" label="" width="100">
  318. <template slot-scope="scope">
  319. <el-button type="primary" size="small" @click="chooseItem(scope.row.enginInfoNo)">选择</el-button>
  320. </template>
  321. </el-table-column>
  322. <el-table-column align="center" prop="orderDate" label="工程登录日期" show-overflow-tooltip></el-table-column>
  323. <el-table-column align="center" prop="enginInfoNo" label="工程信息单" show-overflow-tooltip></el-table-column>
  324. <el-table-column align="center" prop="projectName" label="工程项目" show-overflow-tooltip></el-table-column>
  325. <el-table-column align="center" prop="useUnit" label="使用单位" show-overflow-tooltip></el-table-column>
  326. </el-table>
  327. </div>
  328. <div class="pagination clearfix">
  329. <div class="fr">
  330. <el-pagination
  331. @current-change="dialogTableCurrentChange"
  332. :current-page="dialogTable_currentPage"
  333. :page-size="dialogTable_pageSize"
  334. background
  335. layout="prev, pager, next"
  336. :total="dialogTable_listTotal">
  337. </el-pagination>
  338. </div>
  339. </div>
  340. <div slot="footer" class="dialog-footer">
  341. <el-button @click="isShowDialog = false">关 闭</el-button>
  342. </div>
  343. </el-dialog>
  344. </div>
  345. </template>
  346. <script>
  347. import { getOrderDetail, getComLoginList, getComLoginDetail, getWarehouseList, addCom, editCom, submitCom, checkStock, getWalletList } from "@/api/supply/engin";
  348. import { getDictList, getTypeList, getSalesmanList } from '@/api/common'
  349. import { findElem } from '@/utils/util'
  350. let that
  351. export default {
  352. name: 'CommerceForm',
  353. componentName: 'CommerceForm',
  354. props: ['listItem'],
  355. filters: {
  356. status1Filter(val) {
  357. let STOCK_ORDER_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_START').dictValue;
  358. let STOCK_ORDER_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_END').dictValue;
  359. let STOCK_ORDER_HAVE_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_START').dictValue;
  360. let STOCK_ORDER_HAVE_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_END').dictValue;
  361. let STOCK_ORDER_ALL_NUM = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_ALL_NUM').dictValue;
  362. if (val === '' || val === null || val === undefined) return '未检查';
  363. else if (val <= 0) return '无货';
  364. else if (val > STOCK_ORDER_START && val <= STOCK_ORDER_END) return val;
  365. else if (val >= STOCK_ORDER_HAVE_START && val <= STOCK_ORDER_HAVE_END) return '有货';
  366. else if (val > STOCK_ORDER_ALL_NUM) return '充足';
  367. },
  368. },
  369. data() {
  370. return {
  371. editId: '',
  372. mainForm: {
  373. orderNum: '',
  374. orderDate: '',
  375. // type: '',
  376. jxsNum: '',
  377. jxsName: '',
  378. enginNum: '',
  379. enginName: '',
  380. loginType: '',
  381. factoryNum: '',
  382. company: '',
  383. enginNum: '',
  384. contactMan: '',
  385. tel: '',
  386. phone: '',
  387. address: '',
  388. greeRemark: '',
  389. greeReply: '',
  390. remark: '',
  391. createMan: '',
  392. createDate: '',
  393. fileNum: '',
  394. salesMan: '',
  395. },
  396. mainFormRules: {
  397. // orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  398. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  399. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  400. enginNum: [{ required: true, message: '请输入工程登录编号', trigger: 'blur' }],
  401. // enginName: [{ required: true, message: '请输入项目类别', trigger: 'blur' }],
  402. // loginType: [{ required: true, message: '请输入行业类别', trigger: 'blur' }],
  403. company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  404. // contactMan: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
  405. // tel: [{ required: true, message: '请输入固定电话', trigger: 'blur' }],
  406. // phone: [{ required: true, message: '请输入移动电话', trigger: 'blur' }],
  407. address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  408. enginNum: [{ required: true, message: '请输入工程编号', trigger: 'blur' }],
  409. },
  410. // typeList: [],
  411. stockList: [],
  412. goodsList: [],
  413. multipleSelection: [],
  414. isShowDialog: false, // 工程登录列表 - 弹窗
  415. screenForm: {
  416. enginNum: '',
  417. enginName: '',
  418. company: '',
  419. },
  420. dialogTable_dataList: null, // 工程登录列表 - 列表数据
  421. dialogTable_listLoading: true, // 工程登录列表 - 列表加载loading
  422. dialogTable_currentPage: 1, // 工程登录列表 - 当前页码
  423. dialogTable_pageSize: 10, // 工程登录列表 - 每页数量
  424. dialogTable_listTotal: 0, // 工程登录列表 - 列表总数
  425. warehouseList: [],
  426. warehouseValue: '',
  427. isFirst: false,
  428. salesmanList: [],
  429. }
  430. },
  431. computed: {
  432. isDealer() {
  433. return JSON.parse(localStorage.getItem("supply_user")).isCustomer
  434. },
  435. outSalesmanList() {
  436. let list = [];
  437. if(this.goodsList && this.goodsList.length) {
  438. this.goodsList.forEach(item => {
  439. if(item.serviceId) {
  440. let hasItem = findElem(list, 'adminUserId', item.serviceId);
  441. if(hasItem < 0) {
  442. let obj = this.salesmanList.find(o => o.adminUserId == item.serviceId);
  443. if(obj) {
  444. list.push(obj);
  445. }
  446. }
  447. }
  448. })
  449. if(this.isFirst) {
  450. this.isFirst = false;
  451. }else {
  452. this.mainForm.salesMan = this.goodsList[0].serviceId;
  453. }
  454. }
  455. return list
  456. }
  457. },
  458. watch: {
  459. goodsList: {
  460. handler(newValue, oldValue) {
  461. if(this.goodsList && this.goodsList.length) {
  462. if(this.isFirst) {
  463. this.isFirst = false;
  464. }else {
  465. this.mainForm.salesMan = this.goodsList[0].serviceId;
  466. }
  467. }else {
  468. this.mainForm.salesMan = '';
  469. }
  470. },
  471. immediate: true,
  472. deep: true
  473. }
  474. },
  475. beforeCreate() {
  476. that = this;
  477. },
  478. async created() {
  479. await this.getSalesmanList();
  480. this.getDictList();
  481. this.getWarehouseList();
  482. if(this.listItem) {
  483. this.isFirst = true;
  484. this.editId = this.listItem.parentId;
  485. this.getDetail();
  486. }else {
  487. this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
  488. this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
  489. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  490. this.mainForm.createDate = this.getDate();
  491. }
  492. },
  493. methods: {
  494. // 返回列表
  495. goBack() {
  496. this.$emit('backListFormDetail');
  497. },
  498. getDate() {
  499. var date = new Date();
  500. var seperator1 = "-";
  501. var year = date.getFullYear();
  502. var month = date.getMonth() + 1;
  503. var strDate = date.getDate();
  504. if (month >= 1 && month <= 9) {
  505. month = "0" + month;
  506. }
  507. if (strDate >= 0 && strDate <= 9) {
  508. strDate = "0" + strDate;
  509. }
  510. var currentdate = year + seperator1 + month + seperator1 + strDate;
  511. return currentdate;
  512. },
  513. // 获取产品大类列表
  514. getDictList() {
  515. // getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
  516. // this.typeList = res.data;
  517. // })
  518. getDictList({sysDictEnum: 'STOCK_ORDER'}).then(res => {
  519. this.stockList = res.data;
  520. })
  521. },
  522. // 获取仓库列表
  523. getWarehouseList() {
  524. getWarehouseList({
  525. pageNum: 1,
  526. pageSize: -1
  527. }).then((res) => {
  528. this.warehouseList = res.data.records;
  529. })
  530. },
  531. async getSalesmanList() {
  532. const res = await getSalesmanList({
  533. pageNum: 1,
  534. pageSize: -1,
  535. isCustomer: 0,
  536. status: true,
  537. });
  538. this.salesmanList = res.data.records;
  539. },
  540. // 获取详情
  541. getDetail() {
  542. getOrderDetail({id: this.editId}).then(res => {
  543. let data = res.data;
  544. this.mainForm.orderNum = data.enginOrderId;
  545. this.mainForm.orderDate = data.orderDate;
  546. // this.mainForm.type = data.mainId;
  547. this.mainForm.jxsNum = data.customerNumber;
  548. this.mainForm.jxsName = data.customerName;
  549. this.mainForm.enginNum = data.refEnginRecordNo;
  550. this.mainForm.enginName = data.refProjectName;
  551. this.mainForm.loginType = data.refTradeCategory;
  552. this.mainForm.factoryNum = data.refFactoryNo;
  553. this.mainForm.company = data.refUseUnit;
  554. this.mainForm.enginNum = data.projectNo;
  555. this.mainForm.saleType = data.saleTypeId;
  556. this.mainForm.contactMan = data.refLinkman;
  557. this.mainForm.tel = data.refTel;
  558. this.mainForm.phone = data.refPhone;
  559. this.mainForm.address = data.refInstallAddress;
  560. this.mainForm.greeRemark = data.note2;
  561. this.mainForm.greeReply = data.note1;
  562. this.mainForm.remark = data.remark;
  563. this.mainForm.createMan = data.createBy;
  564. this.mainForm.createDate = data.createTime;
  565. this.mainForm.fileNum = data.fileNo;
  566. this.mainForm.salesMan = data.serviceId;
  567. data.items.forEach(item => {
  568. item.status1 = '';
  569. item.status2 = '';
  570. item.rebateWallets = item.customerWalletList.filter(item => {
  571. return item.type === 'REBATE';
  572. });
  573. item.wallets = item.customerWalletList.filter(item => {
  574. return item.type === 'COMMONLY';
  575. });
  576. })
  577. this.goodsList = data.items;
  578. })
  579. },
  580. // 工程登录列表 - 获取列表
  581. getComLoginList() {
  582. getComLoginList({
  583. pageNum: this.dialogTable_currentPage,
  584. pageSize: this.dialogTable_pageSize,
  585. enginInfoNo: this.screenForm.enginNum,
  586. projectName: this.screenForm.enginName,
  587. useUnit: this.screenForm.company,
  588. examineStatus: 'OK'
  589. }).then(res => {
  590. this.dialogTable_dataList = res.data.records;
  591. this.dialogTable_listTotal = res.data.total;
  592. this.dialogTable_listLoading = false;
  593. })
  594. },
  595. // 工程登录列表 - 打开弹窗
  596. openShareDetail() {
  597. this.isFirst = true;
  598. this.isShowDialog = true;
  599. this.dialogTable_currentPage = 1;
  600. this.getComLoginList();
  601. },
  602. // 工程登录列表 - 更改列表当前页
  603. dialogTableCurrentChange(val) {
  604. this.dialogTable_currentPage = val;
  605. this.getComLoginList();
  606. },
  607. // 提交筛选表单
  608. submitScreenForm() {
  609. this.dialogTable_currentPage = 1;
  610. this.getComLoginList();
  611. },
  612. // 重置筛选表单
  613. resetScreenForm() {
  614. this.$refs.screenForm.resetFields();
  615. this.dialogTable_currentPage = 1;
  616. this.getComLoginList();
  617. },
  618. // 选择工程登录
  619. chooseItem(id) {
  620. getComLoginDetail({
  621. recordNo: id,
  622. enginOrderId: this.mainForm.orderNum
  623. }).then(res => {
  624. this.isShowDialog = false;
  625. let data = res.data;
  626. // this.mainForm.type = data.mainId;
  627. this.mainForm.enginNum = data.enginInfoNo;
  628. this.mainForm.enginName = data.projectName;
  629. this.mainForm.loginType = data.tradeCategory;
  630. this.mainForm.company = data.useUnit;
  631. this.mainForm.enginNum = data.projectNo;
  632. this.mainForm.contactMan = data.linkman;
  633. this.mainForm.tel = data.tel;
  634. this.mainForm.phone = data.phone;
  635. this.mainForm.address = data.installAddress;
  636. this.mainForm.salesMan = data.serviceId;
  637. this.goodsList = data.items.map(item => {
  638. return {
  639. useRefCount: item.useRefCount,
  640. saleTypeId: item.saleTypeId,
  641. saleTypeCode: item.saleTypeCode,
  642. saleTypeName: item.saleTypeName,
  643. materialId: item.materialId,
  644. materialNumber: item.materialNumber,
  645. materialOldNumber: item.materialOldNumber,
  646. materialName: item.materialName,
  647. specification: item.specification,
  648. enginNum: item.qty,
  649. enginPrice: item.price,
  650. enginTotality: item.totalAmount,
  651. historyHasDeliverQty: item.hasDeliverQty,
  652. unit: item.unit,
  653. price: item.price,
  654. qty: item.qty,
  655. customerWalletId2: '',
  656. rebateRate: '',
  657. discAmount: '',
  658. customerWalletId: '',
  659. isDirectTransfer: false,
  660. directTransferQty: '',
  661. hasSendQty: '',
  662. remark: item.remark,
  663. tax: item.taxRate,
  664. status1: '',
  665. status2: '',
  666. rebateWallets: item.customerWalletList.filter(item => {
  667. return item.type === 'REBATE';
  668. }),
  669. wallets: item.customerWalletList.filter(item => {
  670. return item.type === 'COMMONLY';
  671. }),
  672. }
  673. })
  674. this.goodsList.forEach(item => {
  675. item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  676. item.serviceId = (item.wallets && item.wallets.length) ? item.wallets[0].serviceId : '';
  677. item.serviceName = (item.wallets && item.wallets.length) ? item.wallets[0].serviceName : '';
  678. })
  679. })
  680. },
  681. // 删除产品
  682. deleteItem(index) {
  683. this.goodsList.splice(index, 1);
  684. },
  685. // 修改返利钱包
  686. changeFlWallet(index) {
  687. if(this.goodsList[index].customerWalletId2) {
  688. let obj = this.goodsList[index].rebateWallets.find(o => o.customerWalletId == this.goodsList[index].customerWalletId2);
  689. this.goodsList[index].rebateRate = obj.rebateRate;
  690. this.goodsList[index].customerWalletName2 = obj.customerWalletName;
  691. }else {
  692. this.goodsList[index].rebateRate = '';
  693. this.goodsList[index].customerWalletName2 = '';
  694. }
  695. },
  696. // 修改现金钱包
  697. changeXjWallet(index) {
  698. if(this.goodsList[index].customerWalletId) {
  699. let obj = this.goodsList[index].wallets.find(o => o.customerWalletId == this.goodsList[index].customerWalletId);
  700. this.goodsList[index].customerWalletName = obj.customerWalletName;
  701. }else {
  702. this.goodsList[index].customerWalletName = '';
  703. }
  704. },
  705. // 检查库存
  706. checkStock() {
  707. if(!this.warehouseValue) {
  708. return this.$errorMsg('请选择仓库');
  709. }
  710. if(!this.goodsList) {
  711. return this.$errorMsg('请添加货品');
  712. }
  713. let ids = [];
  714. this.goodsList.forEach(item => {
  715. ids.push(item.materialId);
  716. })
  717. checkStock({
  718. correspondId: this.warehouseValue,
  719. materialId: ids.join(',')
  720. }).then(res => {
  721. if(res.data) {
  722. this.goodsList.forEach((item, index) => {
  723. item.status1 = res.data[index].allStockNum;
  724. item.status2 = res.data[index].stockNum;
  725. })
  726. }
  727. })
  728. },
  729. status2Filter(item) {
  730. if (item.status2 === '' || item.status2 === null || item.status2 === undefined) return '未检查';
  731. else if (item.status2 <= 0) return '无货';
  732. else if (item.status2 >= item.qty) return '可用';
  733. else return '短缺';
  734. },
  735. handleSelectionChange(val) {
  736. this.multipleSelection = val;
  737. },
  738. // 保存 / 提交审核
  739. clickSubmitForm(type) {
  740. this.$refs.mainForm.validate((valid) => {
  741. if (valid) {
  742. if(this.goodsList.length < 1) {
  743. return this.$errorMsg('请添加产品');
  744. }
  745. if(this.multipleSelection.length < 1) {
  746. return this.$errorMsg('请选择产品');
  747. }
  748. for(let i=0; i<this.multipleSelection.length; i++) {
  749. if(!this.multipleSelection[i].customerWalletId) {
  750. this.$errorMsg('请选择现金钱包');
  751. return;
  752. }
  753. if(!this.multipleSelection[i].qty) {
  754. this.$errorMsg('请输入数量');
  755. return;
  756. }
  757. if(this.multipleSelection[i].qty > this.multipleSelection[i].enginNum) {
  758. this.$errorMsg('数量不能大于工程信息数量');
  759. return;
  760. }
  761. }
  762. let goodsList = JSON.parse(JSON.stringify(this.multipleSelection));
  763. goodsList.forEach(item => {
  764. delete item.rebateWallets;
  765. delete item.wallets;
  766. })
  767. let saleManItem = this.mainForm.salesMan ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan) : '';
  768. let params = {
  769. enginOrderId: this.mainForm.orderNum,
  770. // orderDate: this.mainForm.orderDate,
  771. // mainId: this.mainForm.type || '',
  772. refEnginRecordNo: this.mainForm.enginNum || '',
  773. refProjectName: this.mainForm.enginName || '',
  774. refTradeCategory: this.mainForm.loginType || '',
  775. refFactoryNo: this.mainForm.factoryNum || '',
  776. refUseUnit: this.mainForm.company || '',
  777. projectNo: this.mainForm.enginNum || '',
  778. refLinkman: this.mainForm.contactMan || '',
  779. refTel: this.mainForm.tel || '',
  780. refPhone: this.mainForm.phone || '',
  781. refInstallAddress: this.mainForm.address || '',
  782. geLiInerNote: this.mainForm.greeRemark || '',
  783. geLiNote: this.mainForm.greeReply || '',
  784. remark: this.mainForm.remark || '',
  785. fileNo: this.mainForm.fileNum || '',
  786. serviceId: this.mainForm.salesMan,
  787. serviceName: saleManItem.nickName,
  788. items: goodsList,
  789. }
  790. if(type === 1) {
  791. if(this.listItem) {
  792. editCom(params).then(res => {
  793. this.$successMsg('编辑成功');
  794. this.goBack();
  795. this.$parent.getList();
  796. })
  797. }else {
  798. addCom(params).then(res => {
  799. this.$successMsg('新增成功');
  800. this.goBack();
  801. this.$parent.getList();
  802. })
  803. }
  804. }else if(type === 2) {
  805. submitCom(params).then(res => {
  806. this.$successMsg('提交审核成功');
  807. this.goBack();
  808. this.$parent.getList();
  809. })
  810. }
  811. }
  812. })
  813. },
  814. }
  815. }
  816. </script>
  817. <style scoped lang="scss">
  818. .detail-container {
  819. width: 100%;
  820. height: 100%;
  821. }
  822. .main-title {
  823. display: flex;
  824. justify-content: space-between;
  825. align-items: center;
  826. margin-top: 20px;
  827. height: 60px;
  828. border-bottom: 1px solid #DCDFE6;
  829. margin-bottom: 20px;
  830. .title {
  831. font-size: 16px;
  832. font-weight: 600;
  833. padding-left: 10px;
  834. }
  835. }
  836. ::v-deep input::-webkit-outer-spin-button,
  837. ::v-deep input::-webkit-inner-spin-button {
  838. -webkit-appearance: none;
  839. }
  840. ::v-deep input[type='number'] {
  841. -moz-appearance: textfield;
  842. }
  843. </style>