commerce_form.vue 33 KB

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