product-management.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <!-- 产品管理 -->
  2. <template>
  3. <div class="product-management">
  4. <template v-if="!addOrUpdateVisible && !attachVisible && !detailVisible && !craftsVisible && !drawVisible && !changeVisible">
  5. <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
  6. <el-form-item label="名称">
  7. <el-input v-model="dataForm.productName" placeholder="产品名称" clearable/>
  8. </el-form-item>
  9. <el-form-item label="产品类别">
  10. <el-select
  11. v-model="dataForm.productType"
  12. remote
  13. placeholder="请选择">
  14. <el-option
  15. v-for="item in optionsType"
  16. :key="item.code"
  17. :label="item.value"
  18. :value="item.code">
  19. </el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button @click="search()">查询</el-button>
  24. <el-button v-if="isAuth('pro:product:save')" type="primary" @click="addOrUpdateHandle(0, false)">创建新产品</el-button>
  25. <el-button v-if="isAuth('pro:product:noteChangeConfig')" type="primary" @click="setNoticeChangeHandel()">变更通知人设置</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <el-table
  29. :data="dataList"
  30. border
  31. v-loading="dataListLoading"
  32. style="width: 100%;">
  33. <el-table-column
  34. label="序号"
  35. type="index"
  36. width="50"
  37. align="center">
  38. </el-table-column>
  39. <el-table-column
  40. prop="productCode"
  41. header-align="center"
  42. align="center"
  43. min-width="100"
  44. :show-tooltip-when-overflow="true"
  45. label="产品编码">
  46. </el-table-column>
  47. <el-table-column
  48. prop="productName"
  49. header-align="center"
  50. align="center"
  51. min-width="140"
  52. :show-tooltip-when-overflow="true"
  53. label="产品名称">
  54. </el-table-column>
  55. <el-table-column
  56. prop="productType"
  57. header-align="center"
  58. align="center"
  59. min-width="120"
  60. :formatter="typeFormat"
  61. label="产品类别">
  62. </el-table-column>
  63. <el-table-column
  64. prop="isCompose"
  65. header-align="center"
  66. align="center"
  67. min-width="120"
  68. :formatter="composeFormat"
  69. label="是否组合产品">
  70. </el-table-column>
  71. <el-table-column
  72. prop="sourceName"
  73. header-align="center"
  74. align="center"
  75. min-width="200"
  76. :show-overflow-tooltip="true"
  77. label="来源">
  78. </el-table-column>
  79. <el-table-column
  80. header-align="center"
  81. align="center"
  82. min-width="140"
  83. :show-overflow-tooltip="true"
  84. label="更改说明">
  85. <template slot-scope="scope">
  86. <span>{{scope.row.noticeChangeRecord?scope.row.noticeChangeRecord.description:''}}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column
  90. header-align="center"
  91. align="center"
  92. label="更改单">
  93. <template slot-scope="scope">
  94. <el-button :disabled="!scope.row.noticeChangeRecord || !scope.row.noticeChangeRecord.attachList || scope.row.noticeChangeRecord.attachList.length === 0" type="text" size="small" @click="changeDetails(scope.row)">查看</el-button>
  95. </template>
  96. </el-table-column>
  97. <el-table-column
  98. header-align="center"
  99. align="center"
  100. label="技术文件">
  101. <template slot-scope="scope">
  102. <el-button :disabled="!scope.row.attachList || scope.row.attachList.length === 0" type="text" size="small" @click="attachDetails(scope.row)">查看</el-button>
  103. </template>
  104. </el-table-column>
  105. <el-table-column
  106. header-align="center"
  107. align="center"
  108. label="对应图纸">
  109. <template slot-scope="scope">
  110. <el-button :disabled="!scope.row.proDrawings || scope.row.proDrawings.length === 0" type="text" size="small" @click="drawDetails(scope.row)">查看</el-button>
  111. </template>
  112. </el-table-column>
  113. <el-table-column
  114. header-align="center"
  115. align="center"
  116. label="对应工艺">
  117. <template slot-scope="scope">
  118. <el-button :disabled="!scope.row.techId" type="text" size="small" @click="techDetails(scope.row.techId)">查看</el-button>
  119. </template>
  120. </el-table-column>
  121. <el-table-column
  122. prop="createTime"
  123. header-align="center"
  124. align="center"
  125. min-width="160"
  126. label="创建时间">
  127. </el-table-column>
  128. <el-table-column
  129. prop="creatorName"
  130. header-align="center"
  131. align="center"
  132. min-width="100"
  133. label="创建人">
  134. </el-table-column>
  135. <el-table-column
  136. prop="notes"
  137. header-align="center"
  138. align="center"
  139. min-width="180"
  140. :show-overflow-tooltip="true"
  141. label="备注">
  142. </el-table-column>
  143. <el-table-column
  144. fixed="right"
  145. header-align="center"
  146. align="center"
  147. width="150"
  148. label="操作">
  149. <template slot-scope="scope">
  150. <el-button v-if="isAuth('pro:product:info')" type="text" size="small" @click="detailHandle(scope.row.productId)">查看</el-button>
  151. <el-button v-if="isAuth('pro:product:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.productId, false)">编辑</el-button>
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. <el-pagination
  156. @size-change="sizeChangeHandle"
  157. @current-change="currentChangeHandle"
  158. :current-page="pageIndex"
  159. :page-sizes="[10, 20, 50, 100]"
  160. :page-size="pageSize"
  161. :total="totalPage"
  162. layout="total, sizes, prev, pager, next, jumper">
  163. </el-pagination>
  164. </template>
  165. <!-- 弹窗, 新增 / 修改 -->
  166. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" @onChose="onChose"></add-or-update>
  167. <detail v-if="detailVisible" ref="detail" @onChose="onChose"/>
  168. <crafts-detail v-if="craftsVisible" ref="craftsDetail" @onChose="onChose"/>
  169. <product-draw-detail v-if="drawVisible" ref="drawDetail" @onChose="onChose"/>
  170. <attach-detail v-if="changeVisible" ref="changeDetail" @onChose="onChose"/>
  171. <attach-detail v-if="attachVisible" ref="attachDetail" @onChose="onChose"/>
  172. </div>
  173. </template>
  174. <script>
  175. import AddOrUpdate from './product-add-or-update'
  176. import Detail from './product-detail'
  177. import { getDictList } from '@/api/dict'
  178. import { getProductList } from '@/api/product'
  179. import CraftsDetail from './crafts-detail'
  180. import ProductDrawDetail from './product-draw-detail'
  181. import AttachDetail from '../common/attach-detail'
  182. export default {
  183. name: 'product-management',
  184. components: {
  185. AttachDetail,
  186. ProductDrawDetail,
  187. CraftsDetail,
  188. AddOrUpdate,
  189. Detail
  190. },
  191. data () {
  192. return {
  193. addOrUpdateVisible: false,
  194. attachVisible: false,
  195. detailVisible: false,
  196. craftsVisible: false,
  197. drawVisible: false,
  198. changeVisible: false,
  199. dataForm: {},
  200. dataList: [],
  201. pageIndex: 1,
  202. pageSize: 10,
  203. totalPage: 0,
  204. dataListLoading: false,
  205. dataListSelections: [],
  206. optionsType: []
  207. }
  208. },
  209. created () {
  210. this.getTypeList()
  211. // this.getStateList()
  212. this.getDataList()
  213. },
  214. methods: {
  215. onChose () {
  216. this.addOrUpdateVisible = false
  217. this.attachVisible = false
  218. this.detailVisible = false
  219. this.craftsVisible = false
  220. this.drawVisible = false
  221. this.changeVisible = false
  222. },
  223. // 获取产品类别字典
  224. getTypeList () {
  225. getDictList({type: 'product_type'}).then(({data}) => {
  226. if (data) {
  227. this.optionsType = data
  228. }
  229. })
  230. },
  231. // 查询
  232. search () {
  233. this.pageIndex = 1
  234. this.getDataList()
  235. },
  236. // 获取数据列表
  237. getDataList () {
  238. this.dataListLoading = true
  239. this.addOrUpdateVisible = false
  240. let params = {
  241. 'current': this.pageIndex,
  242. 'size': this.pageSize,
  243. 'productName': this.dataForm.productName ? this.dataForm.productName : null,
  244. 'productType': this.dataForm.productType ? this.dataForm.productType : null
  245. }
  246. getProductList(params).then(({data}) => {
  247. if (data && data.code === '200') {
  248. this.dataList = data.data.records
  249. this.totalPage = Number(data.data.total)
  250. } else {
  251. this.dataList = []
  252. this.totalPage = 0
  253. }
  254. this.dataListLoading = false
  255. })
  256. },
  257. deleteHandle (id) {
  258. if (!id) return
  259. let ids = []
  260. ids.push(id)
  261. this.$confirm(`确定删除?`, '提示', {
  262. confirmButtonText: '确定',
  263. cancelButtonText: '取消',
  264. type: 'warning'
  265. }).then(() => {
  266. this.$http({
  267. url: this.$http.adornUrl(`/biz-service/product/delete`),
  268. method: 'DELETE',
  269. data: ids
  270. }).then(({data}) => {
  271. if (data && data.code === '200') {
  272. this.$message({
  273. message: '操作成功',
  274. type: 'success',
  275. duration: 1500,
  276. onClose: () => {
  277. this.getDataList()
  278. }
  279. })
  280. } else {
  281. this.$message.error(data.msg)
  282. }
  283. })
  284. }).catch(() => {})
  285. },
  286. // 每页数
  287. sizeChangeHandle (val) {
  288. this.pageSize = val
  289. this.pageIndex = 1
  290. this.getDataList()
  291. },
  292. // 当前页
  293. currentChangeHandle (val) {
  294. this.pageIndex = val
  295. this.getDataList()
  296. },
  297. // 多选
  298. selectionChangeHandle (val) {
  299. this.dataListSelections = val
  300. },
  301. // 新增 / 修改
  302. addOrUpdateHandle (id, disable) {
  303. this.addOrUpdateVisible = true
  304. this.$nextTick(() => {
  305. this.$refs.addOrUpdate.init(id, disable)
  306. })
  307. },
  308. // 转换属性“产品类别”
  309. typeFormat (row) {
  310. if (this.optionsType) {
  311. for (let i = 0; i < this.optionsType.length; i++) {
  312. if (this.optionsType[i].code === row.productType) {
  313. return this.optionsType[i].value
  314. }
  315. }
  316. }
  317. },
  318. // 转换属性“是否组合产品”
  319. composeFormat (row) {
  320. if (!row.isCompose) return ''
  321. if (Number(row.isCompose) === 1) {
  322. return '是'
  323. } else return '否'
  324. },
  325. // 详情
  326. detailHandle (id) {
  327. this.detailVisible = true
  328. this.$nextTick(() => {
  329. this.$refs.detail.init(id)
  330. })
  331. },
  332. // 变更通知人设置
  333. setNoticeChangeHandel () {
  334. // todo
  335. },
  336. // 对应图纸
  337. drawDetails (row) {
  338. this.drawVisible = true
  339. this.$nextTick(() => {
  340. this.$refs.drawDetail.init(row.proDrawings)
  341. })
  342. },
  343. // 对应工艺
  344. techDetails (id) {
  345. this.craftsVisible = true
  346. this.$nextTick(() => {
  347. this.$refs.craftsDetail.init(id)
  348. })
  349. },
  350. // 产品更改通知单
  351. changeDetails (row) {
  352. this.changeVisible = true
  353. this.$nextTick(() => {
  354. this.$refs.changeDetail.init(row.noticeChangeRecord.attachList)
  355. })
  356. },
  357. // 附件
  358. attachDetails (row) {
  359. this.attachVisible = true
  360. this.$nextTick(() => {
  361. this.$refs.attachDetail.init(row.attachList)
  362. })
  363. }
  364. }
  365. }
  366. </script>
  367. <style scoped>
  368. </style>